[Resolu] How concat string of foreach loop

Author Message

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.mp3
3 : 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

Kristian Hole

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}

Kristian

http://ez.no/ez_publish/documenta...tricks/show_which_templates_are_used
http://ez.no/doc/ez_publish/techn...te_operators/miscellaneous/attribute

Stéphane Bullier

Monday 18 September 2006 12:30:18 am

Hello Claudia and Kristian,

Thank very much yours replies. It's working nice.

Cheers

Stéphane

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 18:36:43
Script start
Timing: Jan 18 2025 18:36:43
Module start 'layout'
Timing: Jan 18 2025 18:36:43
Module start 'content'
Timing: Jan 18 2025 18:36:44
Module end 'content'
Timing: Jan 18 2025 18:36:44
Script end

Main resources:

Total runtime0.8434 sec
Peak memory usage4,096.0000 KB
Database Queries65

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0069 588.0469152.6406
Module start 'layout' 0.00690.0026 740.687539.4766
Module start 'content' 0.00960.8321 780.1641596.3516
Module end 'content' 0.84160.0017 1,376.515616.1250
Script end 0.8434  1,392.6406 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00310.3640160.0002
Check MTime0.00130.1531160.0001
Mysql Total
Database connection0.00140.171210.0014
Mysqli_queries0.781092.5980650.0120
Looping result0.00080.0890630.0000
Template Total0.807695.720.4038
Template load0.00210.244620.0010
Template processing0.805595.502020.4027
Template load and register function0.00020.020710.0002
states
state_id_array0.00180.215310.0018
state_identifier_array0.00130.158020.0007
Override
Cache load0.00170.2019360.0000
Sytem overhead
Fetch class attribute can translate value0.00120.137430.0004
Fetch class attribute name0.00100.120170.0001
XML
Image XML parsing0.00120.137730.0004
class_abstraction
Instantiating content class attribute0.00000.002490.0000
General
dbfile0.00100.1214220.0000
String conversion0.00000.000940.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
4content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
5content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
6content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 21
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs