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.

eZ debug

Timing: Jan 19 2025 11:47:17
Script start
Timing: Jan 19 2025 11:47:17
Module start 'content'
Timing: Jan 19 2025 11:47:18
Module end 'content'
Timing: Jan 19 2025 11:47:18
Script end

Main resources:

Total runtime0.8701 sec
Peak memory usage4,096.0000 KB
Database Queries200

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0063 590.2109180.8203
Module start 'content' 0.00630.7071 771.0313565.7422
Module end 'content' 0.71330.1567 1,336.7734337.3750
Script end 0.8700  1,674.1484 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00410.4734210.0002
Check MTime0.00160.1782210.0001
Mysql Total
Database connection0.00070.081110.0007
Mysqli_queries0.784590.16482000.0039
Looping result0.00200.22921980.0000
Template Total0.841696.720.4208
Template load0.00190.220920.0010
Template processing0.839796.507420.4198
Template load and register function0.00020.021710.0002
states
state_id_array0.00100.114210.0010
state_identifier_array0.00160.185020.0008
Override
Cache load0.00160.1891320.0001
Sytem overhead
Fetch class attribute can translate value0.00240.273730.0008
Fetch class attribute name0.00150.172660.0003
XML
Image XML parsing0.00120.138130.0004
class_abstraction
Instantiating content class attribute0.00000.002670.0000
General
dbfile0.00330.3814280.0001
String conversion0.00000.001330.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

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
5content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
8content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
4content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 22
 Number of unique templates used: 7

Time used to render debug report: 0.0002 secs