Nested foreach loops and counter

Author Message

Aleksander Lech

Friday 27 January 2006 3:35:10 am

Hello,

I'm getting strange results in this piece of code:

{foreach $par_array as $parr}
{def $parent=fetch( 'content', 'node', hash( 'node_id', $parr) )}
    <h3>{$parent.name}</h3>
{def $objs=fetch( 'content', 'reverse_related_objects',
                     hash( 'object_id', $node.contentobject_id))}
    <ul>
    {foreach $objs as $obj max ezini('UstawieniaOgolne', 'maxObj', 'zintconf.ini' )}
        {if eq($obj.main_parent_node_id,$parr)}
        <li style="padding-left:10px;"><a href={$obj.main_node.url|ezurl}>{$obj.name|wash}</a></li>
        {/if}
    {/foreach}
        <div class="link-more">
            <a href={$parent.path_identification_string|ezurl}>wi&#281;cej...</a>
        </div>
    </ul>
{/foreach}

maxObj =4

The problem is that maxObj value is used for all ocurrences of inside foreach but not for every occurrence.
I mean that outside foreach occurs once, and inside foreach occurs twice (first with 5 elements, second with 2 elements) but result is first occurence 3 elements and second occurrence 1 element.

I hope you understand my problem.

Greets
Aleksander

Aleksander Lech

Friday 27 January 2006 3:50:22 am

Ok, nevermind,
that foreach loop is badly constructed

A

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 18 2025 11:23:55
Script start
Timing: Jan 18 2025 11:23:55
Module start 'layout'
Timing: Jan 18 2025 11:23:55
Module start 'content'
Timing: Jan 18 2025 11:23:56
Module end 'content'
Timing: Jan 18 2025 11:23:56
Script end

Main resources:

Total runtime0.8547 sec
Peak memory usage4,096.0000 KB
Database Queries52

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0126 587.9375152.6250
Module start 'layout' 0.01260.0043 740.562539.4453
Module start 'content' 0.01690.8362 780.0078428.4297
Module end 'content' 0.85310.0015 1,208.43758.1563
Script end 0.8546  1,216.5938 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00360.4245160.0002
Check MTime0.00140.1686160.0001
Mysql Total
Database connection0.00220.255810.0022
Mysqli_queries0.802993.9387520.0154
Looping result0.00050.0586500.0000
Template Total0.786592.020.3933
Template load0.00230.265820.0011
Template processing0.784291.761420.3921
Template load and register function0.00020.018110.0002
states
state_id_array0.00630.738610.0063
state_identifier_array0.00680.792320.0034
Override
Cache load0.00180.2064160.0001
Sytem overhead
Fetch class attribute can translate value0.00070.082910.0007
Fetch class attribute name0.00140.167020.0007
XML
Image XML parsing0.00010.012610.0001
class_abstraction
Instantiating content class attribute0.00000.001320.0000
General
dbfile0.00070.0770100.0001
String conversion0.00000.001340.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
2content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
5content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
3content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 13
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs