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"]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
Can you please post the PHP source code for your minyan.php page?
Chris
Re: [chris] Text or Image in listing if no image available
By (Deleted User) - September 7, 2009
<div id="mainContent">
<p>Click on the name of Minyan below for more info.</p>
<?php
require_once "/cmsAdmin/lib/viewer_functions.php"; list($minyanRecords, $minyanMetaData) = getRecords(array(
'tableName' => 'minyan',
'perPage' => '10',
));?> <p> </p>
<table width="100%" border="0" cellspacing="1" cellpadding="2">
<tr class="productListingTableHeaderPageNav">
<td height="18" colspan="2" align="left" valign="middle"><?php if ($minyanMetaData['prevPage']): ?>
<a href="<?php echo $minyanMetaData['prevPageLink'] ?>"><< prev</a>
<?php else: ?>
<< prev
<?php endif ?>
- page <?php echo $minyanMetaData['page'] ?> of <?php echo $minyanMetaData['totalPages'] ?> -
<?php if ($minyanMetaData['nextPage']): ?>
<a href="<?php echo $minyanMetaData['nextPageLink'] ?>">next >></a>
<?php else: ?>
next >>
<?php endif ?></td>
</tr>
<tr class="productListingTableHeader">
<td width="80" height="22" align="center" valign="middle">Image</td>
<td align="center" valign="middle">Item CodeProduct Description</td>
</tr>
<?php foreach ($minyanRecords as $record): ?>
<?php $bgColor = (@$bgColor == '#F8F8F8') ? '#E2FEE9' : '#F8F8F8'; ?>
<tr bgcolor="<?php echo $bgColor ?>">
<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>
<td height="80" align="left" valign="top"><h3><a href="<?php echo $record['_link'] ?>"><?php echo $record['minyan_name'] ?></a></h3>
<?php echo $record['address1'] ?> <?php echo $record['address2'] ?><br />
<?php echo $record['city'] ?>, <?php echo $record['state'] ?> <?php echo $record['zip'] ?><br />
<?php echo $record['country'] ?>
</td>
</tr>
<?php endforeach; ?>
<?php if ($minyanMetaData['invalidPageNum']): ?>
Results page '<?php echo $minyanMetaData['page']?>' not found, <a href="<?php echo $minyanMetaData['firstPageLink'] ?>">start over >></a>.<br/>
<br/>
<?php elseif (!$minyanRecords): ?>
<h3><img src="../_img/no_records.gif" width="47" height="47" alt="Sorry... No records were found!" />Sorry... No records were found!</h3>
<br/>
<br/>
<?php endif ?>
<!-- /STEP2: Display Records -->
<tr class="productListingTableHeaderPageNav">
<td height="20" colspan="2" align="left" valign="middle"><?php if ($minyanMetaData['prevPage']): ?>
<a href="<?php echo $minyanMetaData['prevPageLink'] ?>"><< prev</a>
<?php else: ?>
<< prev
<?php endif ?>
- page <?php echo $minyanMetaData['page'] ?> of <?php echo $minyanMetaData['totalPages'] ?> -
<?php if ($minyanMetaData['nextPage']): ?>
<a href="<?php echo $minyanMetaData['nextPageLink'] ?>">next >></a>
<?php else: ?>
next >>
<?php endif ?></td>
</tr>
</table>
<p> </p>
<p> </p>
<!-- end #mainContent -->
</div>
Re: [RapidWeb] Text or Image in listing if no image available
By Chris - September 7, 2009
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.
Chris