Different urls based on file type

5 posts by 2 authors in: Forums > CMS Builder
Last Post: July 4, 2012   (RSS)

By KCMedia - June 30, 2012

Hi

I have some files that are uploaded to the site and they require different urls based on the file type

Eg PDF, xls, docs will all have one kind of URL opened using google docs viewer and then video files and images will be opened using Shadowbox to display them.

Any help will be great
Thanks



Craig

KC Media Solutions

www.kcmedia.biz

Re: [gkornbluth] Different urls based on file type

By KCMedia - July 1, 2012

Hi Jerry

it isnt Craig he is away it is Mark.

thanks for that i am not 100% but this what we have working now for all kinds of pdf, word, excel doc types that get opened.

<?php foreach ($downloadRecords as $record): ?>
<?php foreach ($record['upload'] as $index => $upload): ?>
<a href="http://docs.google.com/gview?url=http://www.domain.com<?php echo $upload['urlPath'] ?>&embedded=true" target="_blank">Download <?php echo htmlencode($upload['info1']) ?></a><br/><br/>
<?php endforeach ?>
<?php endforeach ?>
<?php if (!$downloadRecords): ?>
<?php endif ?>

what we need to do is also upload video files that will open in shadowbox using just the rel="shadowbox" in the url but only if it is a video and not anything else.
Thanks



Craig

KC Media Solutions

www.kcmedia.biz

Re: [kcmedia] Different urls based on file type

By gkornbluth - July 1, 2012

Hi Mark,

I'll try to find something more specific, but basically I'd use the approach above in the foreach loop to sniff out the extension and if it's a video extension, then execute the shadowbox video code.

You might also look at jwplayer if you can't get shadowbox to work

Hope that helps,

Jerry
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Re: [kcmedia] Different urls based on file type

By gkornbluth - July 4, 2012

Hi Mark,

Sorry that it took so long.

Here's the detail page code I'm using with the jwplayer and a multi-record section called articles.

Hope it helps.

Jerry Kornbluth

Head code:
<script type="text/javascript" src="Scripts/jwplayer.js"></script>
Body Code
<?php if ($articlesRecord['article_images_or_video']): ?>
<table width="100%" border="0" align="center" cellpadding="5">
<tr >
<?php foreach ($articlesRecord['article_images_or_video'] as $upload): ?><?php if ($upload['extension'] == 'mp4'): ?>
<td align="center" valign="top" >
<span class="body-text-bold-9"><br />
<?php echo $upload['info1']; ?></span><br />
<span class="body-text-9"><?php echo $upload['info2']; ?><br /><br /></span>
<div id="container">&nbsp;</div>
<script type="text/javascript">
jwplayer("container").setup({

file: "http://96.0.19.45<?php echo $upload['urlPath'] ?>",
height: 420,
width: 510,
image: "http://96.0.19.45<?php foreach ($articlesRecord['video_image'] as $upload): ?><?php echo $upload['thumbUrlPath'] ?><?php endforeach ?>",
autostart: false,
modes: [
{ type: "html5" },
{ type: "flash", src: "player.swf" }
]

});
</script><br /><br /><hr align="center" color="#8FB2D4" width="300">
</td>
<?php else: ?><td valign="top" align="center"><br /><span class="body-text-bold-9">
<?php echo $upload['info1']; ?></span><br />
<span class="body-text-9">
<?php echo $upload['info2']; ?><br /><br /></span><img border="5" style="border-color:#89aed2" src="<?php echo $upload['thumbUrlPath2'] ?>" width="<?php echo $upload['thumbWidth2'] ?>" height="<?php echo $upload['thumbHeight2'] ?>" alt="" /><br /><br /><hr align="center" color="#8FB2D4" width="300">

<?php endif ?></td><?PHP $maxCols=2; if (@++$count % $maxCols == 0): ?></tr><tr><?PHP endif; ?><?php endforeach ?><?php endif ?></tr></table></td>
</tr></table><br />
</td>
</tr>
</table>

The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php