Image Display Dilemma (revised)

3 posts by 2 authors in: Forums > CMS Builder
Last Post: October 6, 2008   (RSS)

Re: [gkornbluth] Image Display Dilemma (revised)

By Dave - October 6, 2008

Hi Jerry,

There's no automatic way to do that with CMS Builder, you can do it with some PHP code though.

In your example $photographyRecord['images'] is a array (or list) of images. So this code let's you loop over them and display each one:

<?php foreach ($photographyRecord['images'] as $upload): ?>

With some more advanced code, you can also refer to the images by number (starting at 0) in the array, like this:

$photographyRecord['images'][0]

So instead of <img src="<?php echo $upload['thumbUrlPath'] ?>"

You would have <img src="<?php echo $photographyRecord['images'][0]['thumbUrlPath'] ?>"

Note that you would want to test the image exists first:

<?php if ($photographyRecord['images'][0]): ?>
...
<?php endif ?>

Hope that helps!
Dave Edis - Senior Developer
interactivetools.com

Re: [gkornbluth] Image Display Dilemma (revised)

By gkornbluth - October 6, 2008

You are soooo good at this!!!!!

Thanks, I'll give it a shot and see where it takes me.

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