Re: [SMARTY] trouble with arrays in template

From: Date: Wed, 23 Jul 2003 01:41:57 +0000
Subject: Re: [SMARTY] trouble with arrays in template
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-9944@lists.php.net to get a copy of this message
You need a numerically indexed array. Just do: $smarty->assign( 'PhotoArray', array( $gallery_dir.'yellow/Bikes0.jpg', ... $gallery_dir.'yellow/Bikes3.jpg' )); and dispense with the "link": <img src="{$PhotoArray[i]}"> You forgot the closing angle bracked on your IMG tag, btw. cheers, Travis Erich Beyrent wrote:
Hi there, I am trying to pass in the following array to my template: $gallery_dir = $DOCUMENT_ROOT.'/photos/gallery/'; $smarty->assign('PhotoArray', array('link' => $gallery_dir.'yellow/Bikes0.jpg'), array('link' => $gallery_dir.'yellow/Bikes1.jpg'), array('link' => $gallery_dir.'yellow/Bikes2.jpg'), array('link' => $gallery_dir.'yellow/Bikes3.jpg'), array('link' => $gallery_dir.'yellow/Bikes3.jpg'), array('link' => $gallery_dir.'yellow/Bikes3.jpg') ); And then in my template, loop through them: <!-- Template code --> <table border="0" cellspacing="0" cellpadding="5">
      {section name=i loop=$PhotoArray}
      <tr>
         <td><img src="{$PhotoArray[i].link}"</td>       </tr>       {/section}
</table> However, none of the images are loading, and none of the template code is showing up at all. What have I done (or not done), and how do I fix it? Thanks for your help! -Erich-
-- Travis Low <mailto:travis@dawnstar.com> <http://www.dawnstar.com>

« previous php.smarty.general (#9944) next »