Share » Forums » Developer » Take content from multiple objects...

Take content from multiple objects and put it into one array

Take content from multiple objects and put it into one array

Tuesday 03 August 2004 7:45:34 pm - 5 replies

Modified on Tuesday 03 August 2004 7:49:36 pm by nathaniel burbank

Author Message

Paul Forsyth

Wednesday 04 August 2004 12:13:49 am

Well, assuming your loop is working, try this:

{let myvar=array()}

  {section var=Polldata loop=fetch('content','list',hash(parent_node_id,$node.node_id,sort_by,$node.sort_array))}

    {let kd=$Polldata.data_map.polloutcome.content}
    {set myvar=$myvar|append($kd)}
    {/let} 

  {/section}

  {set-block scope=root variable=myvar}{$myvar}{/set-block}
  {jpgraph('test1', $myvar, 2) }

{/let} 

paul

--
http://www.visionwt.com

Paul Borgermans

Wednesday 04 August 2004 12:14:37 am

Hi Nathaniel

I stumbled upon the same thing: a template operator for Gantt charts with jpgraph. Finally the template operator we wrote fetches the data itself. If this is not desirable, you could use an <b>{append-block}</b> to a global string variable, seperated for instance with a ','. After the loop you can use the explode operator to create an array out of the string and pass this to your template operator.

http://ez.no/ez_publish/documentation/reference/template_operators/strings/explode

hth

-paul

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans

Paul Borgermans

Wednesday 04 August 2004 12:19:41 am

@paul forsyth

Does appending in a loop works the way you stated? I'm puzzled by your code :-)

-paul

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans

Paul Forsyth

Wednesday 04 August 2004 12:54:04 am

Its a rewrite of the original code but it should work.... ;) I havent tested it.

paul

nathaniel burbank

Wednesday 04 August 2004 12:43:45 pm

Thanks for all your help guys. I really appreciate it.

So the code that Paul ( Forsyth) posted still returns an empty array. I think my confusion here comes from a lack of a in-depth understanding of how exactly the different name spaces work, and how to get data from a loop to the (global?) namespace, so I can use it as a single array.

However, the post by Paul (Borgermans) about using the append-block command got me thinking, and I ended up this code:

 
{let myvar=array() 

  {section var=Polldata loop=fetch('content','list',hash(parent_node_id,$node.node_id,sort_by,$node.sort_array))}
{append-block scope=global variable=myvar}{$Polldata.data_map.polloutcome.content}{/append-block}
{/section}

{jpgraph ("test2", $myvar, 2)}
{/let}  
{/let}

And what do you know, but it works! :-)

Thanks to everyone who responded,
Nathaniel
--
http://politicalretort.org

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

36 542 Users on board!

Forums menu