|
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 |
Chavez Smarty Rookie
Joined: 08 Jul 2003 Posts: 6
|
Posted: Wed Jul 09, 2003 1:06 pm Post subject: Problem with multidimensional arrays |
|
|
Hi!
I pass this array to Smarty with $smarty->assign('company_output', $company_output);
Code: | Array
(
[sv] => Array
(
[0] => Array
(
[id] => 9
[name] => aFirstName
[homesite] => http://www25.something.com
[info] => ...
[date] => 1052738803
)
[1] => Array
(
[id] => 7
[name] => aName
[homesite] => http://www.adomain.com/
[info] => Some information
[date] => 1040075691
)
)
[no] => Array
(
[0] => Array
(
[id] => 13
[name] => aName
[homesite] => http://www.adomain.se/
[info] => Some information
[date] =>
)
)
) |
I'm trying to parse this in my template using a nested section like this:
Code: | {section name=langboxid loop=$company_output}
Some HTML...
{section name=companyid loop=$company_output[langboxid]}
Some HTML..
{/section}
{/section} |
Whats wrong? The first section (langboxid) seems to work fine but my inner section doesen't get parsed at all. Ideas? |
|
Back to top |
|
Chavez Smarty Rookie
Joined: 08 Jul 2003 Posts: 6
|
Posted: Wed Jul 09, 2003 1:17 pm Post subject: |
|
|
I have tried to use {foreach} as well, but there seems to be some stupid mistake from my side cause I can't get that to work either |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Wed Jul 09, 2003 3:00 pm Post subject: |
|
|
section doesn't work here, because you have "sv" and "no" as keys and not "0" and "1"
maybe:
Code: |
{foreach from=$company_output key=langboxid item=compay }
{foreach from=$company key=name item=value}
{$name} => {$value}
{/foreach}
{/foreach}
|
??? |
|
Back to top |
|
Chavez Smarty Rookie
Joined: 08 Jul 2003 Posts: 6
|
Posted: Wed Jul 09, 2003 3:19 pm Post subject: |
|
|
Hi!
Thanks a lot! Of course it worked just the way I wanted. |
|
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
|