|
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 |
laurentq45 Smarty Rookie
Joined: 14 Sep 2006 Posts: 15 Location: France
|
Posted: Thu Sep 14, 2006 9:42 pm Post subject: [Résolu] section et tableau de liens... |
|
|
Bonsoir le Forum,
Je débute avec Smarty, et je l'avoue, en PHP aussi.
J'ai une page de mon site ou j'aimerai alimenter un tableau de liens avec leur bannières respectives.
J'ai donc dans ma page .php :
Code: | $smarty->assign("listsafelistes", array(
'href', array('http://www.lien1.html',
'http://www.lien2.html',
'http://www.lien3.html'),
'src', array('http://image1.gif',
'http://image2.gif',
'http://image3.gif'),
'width',array(88,88,72),
'height',array(31,31,48))); |
et dans ma page .tpl : Code: |
<td width="134" valign="top"><table width="134" border="0" cellspacing="0" cellpadding="0">
{section name=liste loop=$listsafelistes.href))}
<tr>
<td class="menu"><table width="120" height="20" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td class="menu" height="50" align="center">
<a href={$href[liste]}><img src={$src[liste]} width={$width[liste]} height={$height[liste]} border="0"></a>
</td>
</tr>
</table></td>
</tr>
<tr>
<td><img src="images/menu2_separateur.gif" alt="sep" width="164" height="3"></td>
</tr>
{/section}
</table>
|
Mais la page s'affiche comme il faut sauf mon tableau de liens et bannières.
L'affichage se fait comme si mon tableau était vide.
Tout ce qui est dans la {section}{/section} ne s'affiche pas !!
Qu'est-ce que j'ai oublié, ou mal paramétré.
J'ai d'autres {section}{/section} dans la même page, qui fonctionnent. Mais ce ne sont pas des <img>.
Merci de vos lumières
Laurent
Last edited by laurentq45 on Fri Sep 15, 2006 7:34 pm; edited 1 time in total |
|
Back to top |
|
ciboulette Smarty Regular
Joined: 13 Jul 2006 Posts: 45
|
Posted: Fri Sep 15, 2006 10:38 am Post subject: |
|
|
j'ai un peu retoucher (bcp) ton code , comme ça ça marche.
Code: | $smarty->assign('listsafelistes', array(
array( 'href' => 'http://www.lien1.html',
'src' => 'http://image1.gif',
'width' => '90',
'height' => '30'),
array( 'href' => 'http://www.lien2.html',
'src' => 'http://image2.gif',
'width' => '95',
'height' => '35'),
array( 'href' => 'http://www.lien3.html',
'src' => 'http://image3.gif',
'width' => '100',
'height' => '40'),
array( 'href' => 'http://www.lien4.html',
'src' => 'http://image4.gif',
'width' => '105',
'height' => '45')
)); |
Code: | <table width="134" border="0" cellspacing="0" cellpadding="0">
{foreach key=key item=item from=$listsafelistes}
<tr>
<td class="menu"><table width="120" height="20" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td class="menu" height="50" align="center">
<a href={$item.href}><img src={$item.src} width={$item.width} height={$item.height} border="0"></a>
</td>
</tr>
</table></td>
</tr>
<tr>
<td><img src="images/menu2_separateur.gif" alt="sep" width="164" height="3"></td>
</tr>
{/foreach}
</table> |
|
|
Back to top |
|
laurentq45 Smarty Rookie
Joined: 14 Sep 2006 Posts: 15 Location: France
|
Posted: Fri Sep 15, 2006 7:33 pm Post subject: |
|
|
Bonsoir le Forum,
Bonsoir ciboulette,
Un grand merci.
Comment gérer le fait de savoir si l'on doit utiliser {forsearch} plutôt que {section} ou inversement ?
Bonne soirée
Laurent |
|
Back to top |
|
ciboulette Smarty Regular
Joined: 13 Jul 2006 Posts: 45
|
Posted: Sun Sep 17, 2006 12:16 pm Post subject: |
|
|
je dirai que c plutot une preference meme si section a quelque fonction en plus (qui son pas forcement utilisé) , perso je prefere le foreach, surtout que j'utilise parfois pear:pager avec smarty et que avec section ça ne marche pas tres bien alors que avec foreach ça marche tout de suite. |
|
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
|
|