Page 1 of 1

smarty templating system

Posted: Mon Aug 24, 2009 10:05 am
by psychotomus
my code for a sectioned loop

Code: Select all

$data = array('name' => 'tom', 'phone' => '55a35-3425');
$data = array('name' => 'tommy', 'phone' => '55a35-3425');
 
$smarty->assign('users', $data);

my template side

Code: Select all

<table>
{section name=mysec loop=$users}
{strip}
   <tr bgcolor="{cycle values="#aaaaaa,#bbbbbb"}">
      <td>{$users[mysec].name}</td>
      <td>{$users[mysec].phone}</td>
   </tr>
{/strip}
{/section}
</table>
it doesn't show anything on the page when executed. any ideas why?

Re: smarty templating system

Posted: Mon Aug 24, 2009 1:34 pm
by tr0gd0rr
after line 4 on the php file you need $smarty->render().

Also, you might try {foreach} instead of {section}; it has a simpler syntax and is less prone to smarty's limitations and confusing syntax when accessing multi-dimensional arrays.