Text or Image in listing if no image available

4 posts by 2 authors in: Forums > CMS Builder
Last Post: September 7, 2009   (RSS)

By (Deleted User) - September 7, 2009 - edited: September 7, 2009

[font "Calibri"]We are now in the process of replacing Listing Manager with CMS Builder.

[font "Calibri"]In Listing Manager if there was no image, we had a message appear saying NO IMAGE AVAILABLE. How can we do this in CMS Manager? Also, can we display an image instead of the text? (One image to always display if there is no image).

[font "Calibri"]Sample of old site we are now replacing:

[font "Calibri"]http://www.koshertravelinfo.com/davendb/exec/search?lfield1_keyword=&B1=Search&perpage=5&marknew=1&search=1&sort_order=1%2Cabc%2Cforward

New Site:

http://www.koshertravelinfo.com/minyan/minyan.php
[font "Calibri"]Please pardon the appearance, the style sheets are not done yet…

Re: [RapidWeb] Text or Image in listing if no image available

By Chris - September 7, 2009

Hi RapidWeb,

Can you please post the PHP source code for your minyan.php page?
All the best,
Chris

Re: [RapidWeb] Text or Image in listing if no image available

By Chris - September 7, 2009

Hi RapidWeb,

All you need is an If-Else-Endif block. Simply replace this:

<td height="40" align="center" valign="middle"><?php foreach ($record['images'] as $upload): ?>
<?php if ($upload['hasThumbnail']): ?>
<a href="<?php echo $record['_link'] ?>"><img src="<?php echo $upload['thumbUrlPath'] ?>" alt="" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" align="center" /></a><br/>
<?php elseif ($upload['isImage']): ?>
<img src="<?php echo $upload['urlPath'] ?>" alt="" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" align="right" /><br/>
<?php endif ?>
<?php break; ?>
<?php endforeach ?></td>


with this:

<td height="40" align="center" valign="middle">

<?php if (sizeof($record['images']) >= 1): ?>

<?php foreach ($record['images'] as $upload): ?>
<?php if ($upload['hasThumbnail']): ?>
<a href="<?php echo $record['_link'] ?>"><img src="<?php echo $upload['thumbUrlPath'] ?>" alt="" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" align="center" /></a>
<?php elseif ($upload['isImage']): ?>
<img src="<?php echo $upload['urlPath'] ?>" alt="" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" align="right" />
<?php endif ?>
<?php endforeach ?>

<?php else: ?>
<img src="no_image.png" />
<?php endif ?>

</td>


You can replace the HTML in red above with whatever you want to display if there is no uploaded image.

I hope this helps. Please let us know if you have any questions.
All the best,
Chris