Link Uploaded Image (banner) to URL

3 posts by 2 authors in: Forums > CMS Builder
Last Post: February 12, 2011   (RSS)

By csdesign - February 11, 2011

Hello,

My client needed a banner added at the bottom of one or more pages so I setup another image upload without a thumbnail then just loaded the banner in. However, I'm not sure how to link the banner to the url so when someone clicks on the banner it goes to the new page. I'd like to add this to the bottom of each page so she could add more banners with an associated url if she wanted to.

here's the example page - at the bottom:

http://www.aubriericheson.com/biography.php

Thanks! Tina

Re: [csdesign] Link Uploaded Image (banner) to URL

By gkornbluth - February 11, 2011 - edited: February 11, 2011

Hi Tina,

Hi Tina,

One approach could be to use the info1 field of your banner upload (the one used for “Title” in upload field “advanced options”) to enter the URL. Then in your viewer add a hyperlink where you want the banner to show. Use info1 for the URL and display the image where the link text would normally go (code below).

NOTES: You’ll want to use a if statement with the preg_match function to make sure that if there’s no http:// in your url field, the link will still work.

You’ll also want to include some code to limit the amount of banners in a row before a new row is automatically created.

I'd suggest using a thumbnail to display the banner, and setting the maximum vertical (and horizontal) pixel dimensions to suit the page that you're setting up. This way, your client can't inadvertently "break" the page by uploading a giant image.

Here’s the code:
<table>
<tr>
<?php foreach ($your_tableRecords as $record): ?><?php foreach ($record['lbanner_image'] as $upload): ?>

<td>
<a href="<?php echo $upload['info1'] ?>"><img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" style="border:hidden" /></a>
<</td>

<?php endforeach ?><?php endforeach ?>
</tr>
</table>


There are recipes for all of these kinds of implementations in my CMSB Cookbook http://www.thecmsbcookbook.com

Hope that gets you started,

Jerry Kornbluth
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