Forums / Developer / [Resolu] How concat string of foreach loop
Stéphane Bullier
Friday 15 September 2006 6:25:27 am
Hi,
I have this code :
{def $objects=$node.data_map.morceaux.value.columns.sequential.1.rows} {foreach $objects as $index => $object} {$index} : {$object}<br /> {/foreach}
The result is 0 : http://www.archive.org/download/VT1-Francky_Ride/VT1-1-Francky_Ride-Dubby_dubby.mp3 1 : http://www.archive.org/download/VT1-Francky_Ride/VT1-2-Francky_Ride-Lovely_Synthi.mp3 2 : http://www.archive.org/download/VT1-Francky_Ride/VT1-3-Francky_Ride-Le_sens_de_la_vie.mp33 : http://www.archive.org/download/VT1-Francky_Ride/VT1-4-Francky_Ride-Linger_On.mp3
morceaux is matrix attribute type.
I would like concat all the result to have one string of all the url.
How is possible ?
Thank in avance.
Stéphane
Claudia Kosny
Friday 15 September 2006 9:46:37 am
Hello Stephane
Just use the append operator
http://ez.no/doc/ez_publish/technical_manual/3_8/reference/template_operators/strings/append
Greetings from Luxembourg
Claudia
Kristian Hole
Friday 15 September 2006 9:46:47 am
Hello Stéphane,
Did you try something like
{def $string=''} {foreach $node.data_map.morceaux.value.columns.sequential.1.rows as $index => $object} {set $string=concat($string, $object)} {/foreach} Result: {$string}
Kristian http://ez.no/ez_publish/documenta...tricks/show_which_templates_are_used http://ez.no/doc/ez_publish/techn...te_operators/miscellaneous/attribute
Friday 15 September 2006 11:20:17 am
Or even simpler:
{def $result=$node.data_map.morceaux.value.columns.sequential.1.rows|implode(" ")} result:{$result}
Monday 18 September 2006 12:30:18 am
Hello Claudia and Kristian,
Thank very much yours replies. It's working nice.
Cheers