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

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 30 2025 19:39:26
Script start
Timing: Jan 30 2025 19:39:26
Module start 'layout'
Timing: Jan 30 2025 19:39:26
Module start 'content'
Timing: Jan 30 2025 19:39:26
Module end 'content'
Timing: Jan 30 2025 19:39:26
Script end

Main resources:

Total runtime0.0287 sec
Peak memory usage4,096.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0071 588.1406151.2109
Module start 'layout' 0.00710.0044 739.3516220.6875
Module start 'content' 0.01150.0152 960.0391997.7891
Module end 'content' 0.02670.0020 1,957.828133.9922
Script end 0.0287  1,991.8203 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002910.0763140.0002
Check MTime0.00113.8736140.0001
Mysql Total
Database connection0.00155.119910.0015
Mysqli_queries0.00248.358330.0008
Looping result0.00000.062310.0000
Template Total0.00155.310.0015
Template load0.00114.004810.0011
Template processing0.00041.306110.0004
Override
Cache load0.00072.413810.0007
General
dbfile0.00113.928480.0001
String conversion0.00000.029940.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs