Forums / Setup & design / Nested foreach loops and counter

"Please Note:
  • At the specific request of Ibexa we are changing this projects name to "Exponential" or "Exponential (CMS)" effective as of August, 11th 2025.
  • This project is not associated with the original eZ Publish software or its original developer, eZ Systems or Ibexa".

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