Swap for generic image if no upload

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

Re: [gkornbluth] Swap for generic image if no upload

By Dave - November 24, 2008

Hi Jerry,

If there are no images, the code in the foreach loop will never run - since it runs one 'for each' image. So what you need to do is put it below like this:

<?php foreach ($record['listing_page_image'] as $upload): ?>
<?php endforeach ?>

<?php if (!$record['listing_page_image']): ?>
No images found (or show default image)
<?php endif ?>

Let me know if that works for you.
Dave Edis - Senior Developer

Re: [Dave] Swap for generic image if no upload

By gkornbluth - November 24, 2008 - edited: November 25, 2008

It seems the learning curve is filled with hairpin turns...

After beating on it with my big programming hammer for a while based on your direction, It's now working fine.

Thanks Dave for all your help
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