|
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 |
BRDude Smarty Rookie
Joined: 23 Nov 2003 Posts: 17
|
Posted: Thu Jan 01, 2004 4:15 pm Post subject: {section} not traversing arrays with non-standard keys |
|
|
If I assign an array like this:
[php:1:0ad89605fc]$basket = array(
'apple' => 'red',
0 => 'zero is round',
'orange' => 'orange',
'banana' => 'yellow'
);
$template->assign('basket', $basket);[/php:1:0ad89605fc]
{section} will only show the value for 0 and not the other elements. IMHO, {section} should traverse the array using the internal array pointer. |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Thu Jan 01, 2004 5:27 pm Post subject: |
|
|
use {foreach} |
|
Back to top |
|
BRDude Smarty Rookie
Joined: 23 Nov 2003 Posts: 17
|
Posted: Fri Jan 02, 2004 3:33 am Post subject: |
|
|
Hi messju, thanks for pointing that out!
Unfortunately foreach lacks features like index, index_next, step, etc. A simple workaround in the section code would be using array_keys() to build an array of keys and use it to reference the loop array. That way sections would tolerate any kind of array.
Just an idea. |
|
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
|