Forums / Install & configuration / Call node id from within template

Call node id from within template

Author Message

paul bolger

Wednesday 22 April 2009 6:13:39 pm

This is probably really obvious, but how do you call a particular node (by node_id) from within a template? I know you could do a fetch, but is there a way of just saying "get node 2" for example.

Paul Bolger

Carlos Revillo

Thursday 23 April 2009 12:27:41 am

take a look at the fetch functions. you can do a lot with them. for your case just try

    {def $my_node = fetch( "content", "node", hash( "node_id", 2 ) )}

Regards.

paul bolger

Thursday 23 April 2009 1:11:24 pm

Thanks Carlos

I was wondering whether there was a built in function - like $children - with less processing overhead.

Paul Bolger

André R.

Thursday 23 April 2009 2:33:39 pm

And with $children, you mean $node.children?

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

paul bolger

Friday 24 April 2009 6:27:55 pm

$node.children, sorry...

Paul Bolger

André R.

Saturday 25 April 2009 11:16:19 am

But you need to get $node from somewhere to be able to call it, so basically you need to fetch it.
The fetches are only as complex / heawy as you let them (ref list or tree fetch with lots of filters), the only baseline overhead is that the abstraction causes some 3-6 php functions to be called internally to do the fetch.
If you want to lower that then you can create a template function where you do the fetch directly against db or ezp php api(eZContentObjectTreeNode::fetch).

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

eZ debug

Timing: Jan 31 2025 06:10:06
Script start
Timing: Jan 31 2025 06:10:06
Module start 'content'
Timing: Jan 31 2025 06:10:06
Module end 'content'
Timing: Jan 31 2025 06:10:07
Script end

Main resources:

Total runtime0.2762 sec
Peak memory usage2,048.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0064 588.0547180.8203
Module start 'content' 0.00640.0267 768.875098.0547
Module end 'content' 0.03310.2431 866.9297525.8281
Script end 0.2762  1,392.7578 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00351.2666200.0002
Check MTime0.00130.4707200.0001
Mysql Total
Database connection0.00070.259510.0007
Mysqli_queries0.207074.93631410.0015
Looping result0.00120.41811390.0000
Template Total0.242687.810.2426
Template load0.00120.421410.0012
Template processing0.241487.387910.2414
Override
Cache load0.00070.256310.0007
Sytem overhead
Fetch class attribute can translate value0.00060.200610.0006
XML
Image XML parsing0.00020.066310.0002
General
dbfile0.01093.9617200.0005
String conversion0.00000.001930.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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/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