This site has been archived and you can no longer log in or post new messages. For up-to-date community resources please visit

eZ Community » Forums » Setup & design » foreach delimiter behaviour ezp4

foreach delimiter behaviour ezp4

foreach delimiter behaviour ezp4

Wednesday 04 February 2009 9:51:02 pm - 8 replies

I have an array:

{def $relations=fetch('content','related_objects',hash(object_id,$child.contentobject_id))  }

I want to loop through and show just those items that have the class_identifier I want.

{foreach $relations as $prod}
                {if $prod.class_identifier|eq('application')}
<a href={$prod.main_node.url_alias|ezurl}>{$|wash()}</a>
{delimiter}, {/delimiter}

The problem occurs when it displays on the page as putting the delimiter in after the last entry. I thought the


would stop that from occurring.

Am I missing a trick here or is there a better way to accomplish this?

Wednesday 04 February 2009 11:31:44 pm

Tried {continue} ìnstead of {skip}?

Wednesday 04 February 2009 11:47:22 pm

yes, {continue} puts lots of delimiters in as expected.

if the array has say (prod, prod, application, application)

then it will show prod, prod, as the output

if it has (prod, prod)

then it will show prod, prod


Thursday 05 February 2009 9:32:22 am

ok, we'll one way would be to:

{foreach $relations as $prod}
    {if $prod.class_identifier|eq('application')}
    <a href={$prod.main_node.url_alias|ezurl}>{$|wash()}</a>
    {delimiter}{if $prod.class_identifier|ne('application')}, {/if}{/delimiter}

Modified on Thursday 05 February 2009 9:32:47 am by André R

Thursday 05 February 2009 9:49:00 am

What is your exact eZ Publish version? There have been a few issues regarding {skip} and delimiters in 4.0.0, but they should be fixed in 4.0.1 (well, they are in our case).

Thursday 05 February 2009 9:57:46 am

Version: 4.0.1 (4.0.1)
SVN revision: 19785

Thursday 05 February 2009 10:02:06 am

Your 'fix' worked.
Should I report an issue that the {skip} didn't work as anticipated?

Thursday 05 February 2009 10:09:01 am

yes please.

Thursday 08 October 2009 12:17:52 pm


I have the same problem than Dan (with eZP 4.2.0): the delimiter occurs after the last option.

This is my code:

{def $list_enfants=fetch( content, list, hash( parent_node_id, $node.node_id))}

{foreach $list_enfants as $enfant}

     {def $liste_des_id_selectionnes=$enfant.data_map.mes_selections.content}
     {foreach $enfant.data_map.intervention.class_content.options as $option}
           {if $liste_des_id_selectionnes|contains( $ )|not}
                  {$|wash( xhtml )}
            {delimiter} - {/delimiter}

I have tried the solution proposed by André but it doesn't works. In any case, I get:

option 1 - option 2 - option 3 -


Modified on Thursday 08 October 2009 12:18:17 pm by Pascal France


You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from