Précédent   Forum des professionnels en informatique > PHP > Bibliothèques et frameworks > Templates > Smarty
Smarty Forum d'entraide sur le moteur de templates Smarty. Avant de poster -> FAQ Smarty et Cours Smarty
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 12/01/2008, 18h06   #1
Membre du Club
 
Inscription : décembre 2007
Messages : 94
Détails du profil
Informations forums :
Inscription : décembre 2007
Messages : 94
Points : 40
Points : 40
Par défaut Faire un saut de ligne toutes les X itération

Bonsoir,
J'ai une section dans une table :
Code :
1
2
3
4
5
6
7
8
 
<tr id="tr1">
        {section name=online loop=$table_quien_ligne}
             <td id="tdd{$smarty.section.online.index}" class="mbl_join_img"><img src="http://www.monsite.com/forum/images/{$table_quien_ligne[online].image_forum}" alt="{$table_quien_ligne[online].pseudo}" title="{$table_quien_ligne[online].pseudo}" /></td>
 
        {/section}
 
        </tr>
Et je souhaite changer de ligne (faire un <TR>) tous les 9 passages dans la boucle.

En php pas de soucis j'utilise un if sur une valeur que j'incrémente (inc++) mais en langage smarty je ne trouve pas mon bonheur.

Merci pour votre aide.
PseT34 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 12/01/2008, 20h25   #2
Membre Expert
 
Avatar de eric.pommereau
 
Homme ERIC POMMEREAU
Ingénieur intégration
Inscription : décembre 2004
Messages : 683
Détails du profil
Informations personnelles :
Nom : Homme ERIC POMMEREAU
Âge : 38
Localisation : France

Informations professionnelles :
Activité : Ingénieur intégration
Secteur : Administration - Collectivité locale

Informations forums :
Inscription : décembre 2004
Messages : 683
Points : 1 294
Points : 1 294
Bonjour,

Une possibilité (je n'ai pas testé) :

Citation:
Simple Solution for any number of columns

This is for any number of columns, and its short and painless:
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
{* Monte Möhrt March 4, 2002 *}
{* $cols is the number of columns you want *}
<TABLE border=1>
    <TR>
    {section name=numloop loop=$data}
        <TD>{$data[numloop]}</TD>
        {* see if we should go to the next row *}
        {if not ($smarty.section.numloop.rownum mod $cols)}
                {if not $smarty.section.numloop.last}
                        </TR><TR>
                {/if}
        {/if}
        {if $smarty.section.numloop.last}
                {* pad the cells not yet created *}
                {math equation = "n - a % n" n=$cols a=$data|@count assign="cells"}
                {if $cells ne $cols}
                {section name=pad loop=$cells}
                        <TD>&nbsp;</TD>
                {/section}
                {/if}
                </TR>
        {/if}
    {/section}
</TABLE>
Source : http://smarty.incutio.com/?page=SmartyColumnsTutorial

ça me semble correpondre à ce que tu cherches à faire.

@+
eric.pommereau est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 12/01/2008, 22h34   #3
Membre du Club
 
Inscription : décembre 2007
Messages : 94
Détails du profil
Informations forums :
Inscription : décembre 2007
Messages : 94
Points : 40
Points : 40
C'est parfait, merci beaucoup, une fois de plus Eric.
PseT34 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 13/01/2008, 10h30   #4
Membre Expert
 
Avatar de eric.pommereau
 
Homme ERIC POMMEREAU
Ingénieur intégration
Inscription : décembre 2004
Messages : 683
Détails du profil
Informations personnelles :
Nom : Homme ERIC POMMEREAU
Âge : 38
Localisation : France

Informations professionnelles :
Activité : Ingénieur intégration
Secteur : Administration - Collectivité locale

Informations forums :
Inscription : décembre 2004
Messages : 683
Points : 1 294
Points : 1 294
De nada
eric.pommereau est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 12h00.


 
 
 
 
Partenaires

Hébergement Web