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.

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 19 2025 06:05:38
Script start
Timing: Jan 19 2025 06:05:38
Module start 'layout'
Timing: Jan 19 2025 06:05:38
Module start 'content'
Timing: Jan 19 2025 06:05:38
Module end 'content'
Timing: Jan 19 2025 06:05:38
Script end

Main resources:

Total runtime0.0149 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0064 589.2813152.6406
Module start 'layout' 0.00640.0023 741.921939.4766
Module start 'content' 0.00870.0039 781.398493.4609
Module end 'content' 0.01260.0022 874.859434.3047
Script end 0.0149  909.1641 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002919.6764140.0002
Check MTime0.00138.5834140.0001
Mysql Total
Database connection0.00096.330710.0009
Mysqli_queries0.002214.989130.0007
Looping result0.00000.106910.0000
Template Total0.001912.610.0019
Template load0.00085.687710.0008
Template processing0.00106.852410.0010
Override
Cache load0.00063.787610.0006
General
dbfile0.00021.419980.0000
String conversion0.00000.054240.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs