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

Sections: iterate trough multidimensional array

 
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 -> General
View previous topic :: View next topic  
Author Message
mykro
Smarty n00b


Joined: 29 Apr 2003
Posts: 3

PostPosted: Tue Apr 29, 2003 8:22 pm    Post subject: Sections: iterate trough multidimensional array Reply with quote

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


Joined: 29 Apr 2003
Posts: 21

PostPosted: Tue Apr 29, 2003 10:55 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
mykro
Smarty n00b


Joined: 29 Apr 2003
Posts: 3

PostPosted: Wed Apr 30, 2003 4:40 am    Post subject: Reply with quote

works, thanks
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 -> General 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