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.