I have a question regarding smarty templates, I’m using PHP and Smarty in order to generate pages. I would like to somehow count or determine first and last row of table. So I can set different CSS for first and last TR or leave it as it is, if it’s only 1 TR.
Hope it makes sense what im after. Thanks in advance.
<table class="table-paddings-2" cellspacing="0" cellpadding="0">
<tr>
<th class="table-gray-th-noborder">Search Type</th>
<th class="table-gray-th-noborder">Average Turnaround Time</th>
</tr>
{foreach key=obk item=row from=$report}
<tr>
<td class="td-border-top-only text-align-left">{$row.SearchName}</td>
<td class="td-border-top-only text-align-left">{$row.tt}</td>
</tr>
{/foreach}
</table>
Documentation is your friend: http://www.smarty.net/docsv2/en/language.function.foreach.tpl
Examples 7.12, 7.13: