Share » Forums » Developer » Building an array inside a loop

Building an array inside a loop

Building an array inside a loop

Wednesday 09 February 2005 1:54:08 am - 4 replies

Author Message

Tom Couwberghs

Wednesday 09 February 2005 2:02:07 am

Try something like:

{let filtered_items=array()}
   {section name=Child loop=fetch('content','list', hash(parent_node_id, $node.node_id))}
   {section-exclude match=$Child:item.data_map.category.content.enumobject_list.0.enumvalue|eq('kopes')}
   {section-exclude match=$Child:item.data_map.category.content.enumobject_list.0.enumvalue|eq('skankes')}
   {section-exclude match=$Child:item.data_map.category.content.enumobject_list.0.enumvalue|eq('bytes')}

    {set filtered_items=$filtered_items|append($Child:item)}
   {/section}

    {$filtered_items|attribute(show)}
{/let}

Anja Lundin

Wednesday 09 February 2005 2:13:25 am

Thanks Tom!
The attribute(show), doesnt show anything. I guess it means the array is empty? I'll try to search on the webbpage and see if I find something more on arrays.

------------------------------------
Anja Lundin
Developer, Novitell AB
Sweden

www.novitell.se

Tom Couwberghs

Wednesday 09 February 2005 3:36:53 am

OK i've found the problem. This trick doesn't work with section name. Try it like this:

{let filtered_items=array()}
{section var=Child loop=fetch('content','list', hash(parent_node_id, $node.node_id))}
    ...
   {set filtered_items=$filtered_items|append($Child.item)} 
{/section}
{/let}

Now the set and let are in the same scope, so that should work.

Anja Lundin

Wednesday 09 February 2005 4:32:05 am

It works now!
Thanks a lot, Tom!
/Anja

------------------------------------
Anja Lundin
Developer, Novitell AB
Sweden

www.novitell.se

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

36 542 Users on board!

Forums menu