Share » Forums » Setup & design » loop with {section} syntax to...

loop with {section} syntax to {foreach} syntax

loop with {section} syntax to {foreach} syntax

Thursday 15 March 2007 11:39:03 am - 2 replies

Author Message

Claudia Kosny

Thursday 15 March 2007 2:18:24 pm

Hi Pascal

You have the variables the wrong way around. This should (hopefully) be correct:

{foreach  $object.contentobject_attributes as $ContentObjectAttribute}
    {attribute_view_gui attribute=$ContentObjectAttribute}
{/foreach}

The if statement in your code will most likely not work because $ContentObjectAttribute is an object, which you want to compare with the string 'body'. Therefore I left it out.

Claudia

Pascal France

Thursday 15 March 2007 4:20:23 pm

Thanks a lot Claudia,

The two working syntaxes are:

<section name=ContentObjectAttribute loop=$object.contentobject_attributes>
<if eq($ContentObjectAttribute:item.contentclass_attribute.identifier,body)>
<attribute_view_gui attribute=$ContentObjectAttribute:item>
</if>
</section>

and:

{foreach  $object.contentobject_attributes as $ContentObjectAttribute}
{if eq($ContentObjectAttribute.contentclass_attribute.identifier,body)}
{attribute_view_gui attribute=$ContentObjectAttribute}
{/if}
{/foreach}

So we have to:
- permutate "ContentObjectAttribute" and "object.contentobject_attributes"
- remove ":item"

Regards

Pascal

Ce qui embellit le désert c'est qu'il cache un puits... quelque part... (A. de Saint-Exupéry) - http://luxpopuli.fr/eZ-Publish

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

36 542 Users on board!

Forums menu