|
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 |
mykro Smarty n00b
Joined: 29 Apr 2003 Posts: 3
|
Posted: Tue Apr 29, 2003 8:22 pm Post subject: Sections: iterate trough multidimensional array |
|
|
I need to loop trough a multidimensional array like this:
Array (2)
data => Array (5)
0 => Array (8)
0 => 1
id => 1
1 => Home
title => Home
2 => Home
category => Home
3 => 0
order => 0
1 => Array (8)
0 => 2
id => 2
1 => Useful Links
title => Useful Links
2 => Home
category => Home
3 => 1
order => 1
[...]
in other words - i need to iterate trough $pages["data"]. i used the following assign to add the value to the smarty object:
$pages["data"] = $db->result;
$Engine->assign("pages", $pages);
then i have a section like this:
{section name="pages" loop=$pages.data }
<tr>
<td>{$pages[pages].id}</td>
<td>{$pages[pages].title}</td>
<td>{$pages[pages].category}</td>
<td>{$pages[pages].order}</td>
</tr>
{/section}
but doesn't work :(
hop you can help me
regards |
|
Back to top |
|
Brian Smarty Rookie
Joined: 29 Apr 2003 Posts: 21
|
Posted: Tue Apr 29, 2003 10:55 pm Post subject: |
|
|
The loop=$pages.data only determines how many times the loop is executed. You should probably have to change your inner to: {$pages.data[pages].id} etc... |
|
Back to top |
|
mykro Smarty n00b
Joined: 29 Apr 2003 Posts: 3
|
Posted: Wed Apr 30, 2003 4:40 am Post subject: |
|
|
works, thanks |
|
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
|