|
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 |
boup Smarty Rookie
Joined: 25 Aug 2010 Posts: 5
|
Posted: Wed Aug 25, 2010 2:56 pm Post subject: [résolu] problème de td avec smarty |
|
|
bonjour,
Je suis nouveau sur le forum et je viens d'installer Smarty donc je galère un peu.
j'ai réussi à mettre</tr><tr> quand j'arrive à 4 <td></td>.
Les <td></td> dépendent d'une db et j'aimerai savoir comment faire, pour que quand le nombre d'éléments dans ma db n'est pas un multiple de 4, ajouter des <td>vide</td> pour arriver à un multiple de 4.
j'espère que vous avez compris mes explications
voici mon code :
Code: |
{foreach from =$test name=a key=k item=v}
{if $smarty.foreach.a.index eq 0 || $smarty.foreach.a.index eq '4%0'}<tr>{/if}
<td><span class="gras">{$v.nom}</span><br />{$v.fonction}<br />Tel. {$v.tel}<br /><a href="mailto:{$v.mail}">Contacter par mail</a></td>
{if $smarty.foreach.a.iteration eq '4%0'}</tr>{/if}
{/foreach}
|
j'ai trouvé la solution
Code: |
{foreach from =$test name=a key=k item=v}
{if $smarty.foreach.a.index eq 0 || $smarty.foreach.a.index%4 eq 0}<tr>{/if}
<td><span class="gras">{$v.nom}</span><br />{$v.fonction}<br />Tel. {$v.tel}<br /><a href="mailto:{$v.mail}">Contacter par mail</a></td>
{if $smarty.foreach.a.iteration eq $test|@count && $smarty.foreach.a.iteration%4 neq 0}<td colspan="{math equation='x-y' x=4 y=$smarty.foreach.a.iteration%4}"></td><tr> {/if}
{if $smarty.foreach.a.iteration%4 eq 0}</tr>{/if}
{/foreach}
|
|
|
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
|