Forums / Setup & design / Problems with nested loops

Problems with nested loops

Author Message

Gabriel Ambuehl

Sunday 27 April 2003 11:10:09 am

I have a rather complex structure of nested arrays, basically, it's
array(array(array(hash)))) over which I need to iterate and turn it into a table.
For starters, I used:
<table border="1">
{section name=week loop=5}
<tr>
{section name=weekday loop=7}
<td>{$week:item} | {$weekday:item} </td>
{/section}
</tr>

{/section}
</table>

but while the basic table (5rows, 7columns) comes out correctly, only {$week:item} gets printed, {$weekday:item} remains empty.

Furthermore, I couldn't figure out how I can use the {$week:item} data as index for my array structure (I need to use $week as first index, $weekday as second and more not yet integrated nested loops for the remaining indices).

For several reasons, I prefer it to work with indices instead of looping over the array directly so that's not really what I'm after (couldn't get it to work either).

Visit http://triligon.org

Paul Borgermans

Sunday 27 April 2003 11:19:31 am

Nested loops are nested namespaces!
Try the following and note $week:weekday:item
----------------
<table border="1">
{section name=week loop=5}
<tr>
{section name=weekday loop=7}
<td>{$week:item} | {$week:weekday:item} </td>
{/section}
</tr>

{/section}
</table>
-------------------------------

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans

Gabriel Ambuehl

Sunday 27 April 2003 12:32:23 pm

Thanks, that works perfectly.

Visit http://triligon.org