|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
susawx Smarty n00b
Joined: 18 Jun 2010 Posts: 1
|
Posted: Fri Jun 18, 2010 8:25 pm Post subject: Adding a different class name with foreach |
|
|
HI! I have this code and I want to generate a different class name to the <tr> tag like extra1, extra2, extra3, etc How can I do so?
{* Extra Fields *}
{foreach from=$extrafields item=extras}
<tr class="????">
<td><strong>{$extras.title}:</strong></td>
<td>
{if isset($extras.value)}
{foreach key=key item=item from=$extras.value}
{$item|nl2br}<br />
{foreachelse}
{$extras.value}
{/foreach}
{/if}
</td>
</tr>
{/foreach}
Thanks!!! |
|
Back to top |
|
jpiercemaine Smarty Regular
Joined: 24 Sep 2009 Posts: 82
|
Posted: Fri Jun 18, 2010 8:52 pm Post subject: a |
|
|
if you are just going to name them based on the iteration : 1,2,3,4,5,etc...
Code: |
{* Extra Fields *}
{foreach from=$extrafields item=extras name=myextras}
<tr class="extra{$smarty.foreach.myextras.iteration}">
<td><strong>{$extras.title}:</strong></td>
<td>
{if isset($extras.value)}
{foreach key=key item=item from=$extras.value}
{$item|nl2br}<br />
{foreachelse}
{$extras.value}
|
_________________ ~ jpierce |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|