Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

[Résolu] section et tableau de liens...

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: French
View previous topic :: View next topic  
Author Message
laurentq45
Smarty Rookie


Joined: 14 Sep 2006
Posts: 15
Location: France

PostPosted: Thu Sep 14, 2006 9:42 pm    Post subject: [Résolu] section et tableau de liens... Reply with quote

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 Idea lumières Idea Wink

Laurent


Last edited by laurentq45 on Fri Sep 15, 2006 7:34 pm; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
ciboulette
Smarty Regular


Joined: 13 Jul 2006
Posts: 45

PostPosted: Fri Sep 15, 2006 10:38 am    Post subject: Reply with quote

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
View user's profile Send private message
laurentq45
Smarty Rookie


Joined: 14 Sep 2006
Posts: 15
Location: France

PostPosted: Fri Sep 15, 2006 7:33 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website MSN Messenger
ciboulette
Smarty Regular


Joined: 13 Jul 2006
Posts: 45

PostPosted: Sun Sep 17, 2006 12:16 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: French All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP