Forums / Developer / Working with Arrays and Nodes

Working with Arrays and Nodes

Author Message

Alejandro Dominguez

Wednesday 15 June 2011 2:51:54 am

Hello folks,

I have created a fetch to extract some nodes and now I would like to create an array with some of the nodes. If they pass a condition I will insert it in the array.

However I'm not able to create the right code to insert in the array.

I created an Array

 {def $myarray=Array()}

and then I tried to insert it with this sentence

{set $myarray[$counter]=$nodes[$to_display]}

I have also tried the insert

 

<span class="line">{$myarray | insert( 0, $nodes[$to_display] )}</span>

I think it's a noob syntax problem :$ . Can you help me?

 

Cheers,

Alejandro

Carlos Revillo

Wednesday 15 June 2011 3:42:42 am

hi Alejandro. i think what you need is append function. something like:

 {def $myarray = array()}
{set $myarray = $myarray|append( $node )}

but, without knowing properly what you are trying to achieve, i would say, in general is not a good idea to fetch all nodes and add them to another array only if they pass specific conditions. 

if those nodes are taken by a fetch, i would go for a way (probably a custom function or whatever) trying to only return the nodes you need from database, instead of fetching all if you don't need all of them. 

Marko Žmak

Wednesday 15 June 2011 7:03:12 am

"

if those nodes are taken by a fetch, i would go for a way (probably a custom function or whatever) trying to only return the nodes you need from database, instead of fetching all if you don't need all of them. 

"

An extended attribute filter would probably be the best.

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

Carlos Revillo

Wednesday 15 June 2011 7:06:54 am

"

An extended attribute filter would probably be the best.

"

yep. sure!. or even better, an ezfind query :).

Alejandro Dominguez

Friday 17 June 2011 2:03:16 am

Hi Carlos & Marko!

The Append solution has worked well!  The extended attribute filter seems to be a better solution, so I'm going to try this now.

 

Thanks for your answers :)

 

cheers

Alejandro

eZ debug

Timing: Jan 18 2025 00:08:14
Script start
Timing: Jan 18 2025 00:08:14
Module start 'content'
Timing: Jan 18 2025 00:08:15
Module end 'content'
Timing: Jan 18 2025 00:08:15
Script end

Main resources:

Total runtime1.0289 sec
Peak memory usage4,096.0000 KB
Database Queries202

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0059 593.3594180.8438
Module start 'content' 0.00590.8798 774.2031613.7578
Module end 'content' 0.88570.1431 1,387.9609337.3750
Script end 1.0288  1,725.3359 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00410.3947210.0002
Check MTime0.00150.1445210.0001
Mysql Total
Database connection0.00080.077710.0008
Mysqli_queries0.949092.23472020.0047
Looping result0.00240.23702000.0000
Template Total1.002597.420.5012
Template load0.00190.187920.0010
Template processing1.000597.245620.5003
Template load and register function0.00010.010410.0001
states
state_id_array0.00170.168110.0017
state_identifier_array0.00090.084220.0004
Override
Cache load0.00170.1674410.0000
Sytem overhead
Fetch class attribute can translate value0.00120.118940.0003
Fetch class attribute name0.00130.123270.0002
XML
Image XML parsing0.00150.142540.0004
class_abstraction
Instantiating content class attribute0.00000.001680.0000
General
dbfile0.00360.3451350.0001
String conversion0.00000.000630.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
3content/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
11content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
4content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
2content/datatype/view/ezxmltags/quote.tpldatatype/ezxmltext/quote.tplextension/ezwebin/design/ezwebin/override/templates/datatype/ezxmltext/quote.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 27
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs