How to show only first image only on albumList.php?

4 posts by 3 authors in: Forums > CMS Builder
Last Post: December 14, 2011   (RSS)

By jacgo - December 14, 2011

Hi, dear all

My album list page is albumList.php

How to show only first image on the album List page?
[url "http://www.rscf.org.tw/site/albumList.php"]http://www.rscf.org.tw/site/albumList.php[/#0066cc][/url]

code[/url] below:

<table border="0" cellpadding="0" cellspacing="0" width="228" id="table1">
<tr>
<?php foreach ($albumRecords as $record): ?>
<td style="border-style: solid; border-width: 1px" bordercolor="#D4D5D6"><table border="0" cellpadding="0" cellspacing="5" width="100%" id="table2">
<tr>
<td width="7%">&nbsp;</td>
<td width="88%"><p class="homeProductName"><?php echo $record['title'] ?></p></td>
<td width="5%">&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td height="70" valign="top"><p class="body"><a href="<?php echo $record['_link'] ?>"><?php echo $record['_link'] ?></a></p></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td height="70" valign="top"><?php foreach ($record['photos'] as $upload): ?>
<?php if ($upload['hasThumbnail']): ?>
<img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" /><br/>
<?php endif ?>
<?php endforeach ?></td>
<td>&nbsp;</td>
</tr>
</table></td>
<?php $maxCols=3; if (@++$count % $maxCols == 0): ?>
</tr>
<tr>
<?php endif; ?>
<?php endforeach ?>
</tr>
</table>



Thanks!

Jacgo

Re: [jacgo] How to show only first image only on albumList.php?

By Jason - December 14, 2011

Hi Jacgo,

You can use a break right after your output a thumbnail like this:

<td height="70" valign="top">
<?php foreach ($record['photos'] as $upload): ?>
<?php if ($upload['hasThumbnail']): ?>
<img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" /><br/>
<?php break; ?>
<?php endif ?>
<?php endforeach ?>
</td>


Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] How to show only first image only on albumList.php?

By jacgo - December 14, 2011

Hi Jason

It's looks great!

other issue:

How can I post my code on forum like yours? (code formating)
Your code looks clear.
it's help everyone to look it.

Thanks for your help.



Jacgo