Text or Image in listing if no image available

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

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: [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>&nbsp;</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'] ?>">&lt;&lt; prev</a>
<?php else: ?>
&lt;&lt; prev
<?php endif ?>
- page <?php echo $minyanMetaData['page'] ?> of <?php echo $minyanMetaData['totalPages'] ?> -
<?php if ($minyanMetaData['nextPage']): ?>
<a href="<?php echo $minyanMetaData['nextPageLink'] ?>">next &gt;&gt;</a>
<?php else: ?>
next &gt;&gt;
<?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'] ?> &nbsp;&nbsp;&nbsp;<?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 &gt;&gt;</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'] ?>">&lt;&lt; prev</a>
<?php else: ?>
&lt;&lt; prev
<?php endif ?>
- page <?php echo $minyanMetaData['page'] ?> of <?php echo $minyanMetaData['totalPages'] ?> -
<?php if ($minyanMetaData['nextPage']): ?>
<a href="<?php echo $minyanMetaData['nextPageLink'] ?>">next &gt;&gt;</a>
<?php else: ?>
next &gt;&gt;
<?php endif ?></td>
</tr>
</table>
<p>&nbsp;</p>
<p>&nbsp;</p>

<!-- end #mainContent -->
</div>

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