smarty templating system

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
psychotomus
Forum Contributor
Posts: 487
Joined: Fri Jul 11, 2003 1:59 am

smarty templating system

Post 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?
User avatar
tr0gd0rr
Forum Contributor
Posts: 305
Joined: Thu May 11, 2006 8:58 pm
Location: Utah, USA

Re: smarty templating system

Post 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.
Post Reply