Forums / General / How to add more value to var in templates ?

How to add more value to var in templates ?

Author Message

Marvix Marx

Saturday 29 December 2007 10:38:20 pm

Hi ..

I had bought flash slide player (monoslideshow.com) XML based, I need to create xml file with the seeting and the images.

I wrote an extension to write the file and adding the data from template, but the problem with collecting the data in the template :(

I need to fetch a node where the images and to get the data in array:
$data[]=array($ImageURL, $ImagePath)

I had tried set-block, but with this way I need to run loop and with loop will write the file twice.
I need to collect the data into array and then to use the file write operator, any solution for this ?

Or should I just write in php for this ?

Thanks in advanced.

André R.

Sunday 30 December 2007 7:13:27 pm

It's probably best to do this in php, but in templates you can do your example like this:

{def $arr = array()}
{foreach $some_array as $el}
{set $arr = $arr|append(  array(  $el.url, $el.path ) )}
{/foreach}

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Marvix Marx

Sunday 30 December 2007 10:30:34 pm

I have done it with php, but I don`t know to extract the values from XML :(

any clue ?

André R.

Monday 31 December 2007 3:43:03 am

If you use eZ Publish 4.0:
http://ez.no/developer/contribs/template_plugins/ez_template_dom

But how is the code working now?
* fetching data from some external db
* generating xml file
* showing some values from xml file instead of directly from db??
* xml file also used for flash??

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Marvix Marx

Monday 31 December 2007 4:37:15 am

The images under media node, from the sql debug I copied the query, and the result was I as I need, but as XML .. tried with xmldom and xmldocument but no result.

am using ezp 4.

I`ll test you template code when I go home.