Forums / Setup & design / How to get parent of a node?

How to get parent of a node?

Author Message

Lydie Soler

Friday 05 August 2005 2:36:34 am

Hi,
I would like to know how I can get the parent of a node.

Thanks for your help

Albert Hornos

Friday 05 August 2005 5:29:59 am

Lydie have you tried:

{$node.parent}

Sometime easy things can work ;)

Lydie Soler

Friday 05 August 2005 5:51:09 am

I should have been more precise. I am using the treemenu and I wanted to know the parent of a node selected by this treemenu... But as far I as understood the documentation I don't think it can be done.
Am I wrong?

Xavier Dutoit

Friday 05 August 2005 7:09:21 am

Slap the node until he cries and his parents are going to come. Then you can get them ;) (By night, that's likely you will only get the mother).

I don't get the problem. Once you select a node (using the treemenu or otherwise), it's displayed in the full format.

Then, with {$node.parent} on the full.tpl or the template overrided you display the parent.

What am I missing ?

http://www.sydesy.com

David Eriksson

Friday 05 August 2005 7:20:20 am

The treemenu operator doesn't give you full nodes; see http://ez.no/doc/ez_publish/technical_manual/3_6/reference/template_operators/miscellaneous/treemenu

Among the things it does give you, however, is the IDs. So you can always fetch() each and every node. Can be quite a nightmare performance-wise of course.

/David

Lydie Soler

Friday 05 August 2005 7:27:27 am

yes that's what I add noticed. But can I with this node-id get its parent-node? don't think so...
you agree?

Xavier Dutoit

Friday 05 August 2005 7:59:32 am

Hi,

assuming you're able to get the id of the node you want (from treemenu) into $currentnode

<ul>
{def $mainMenu=treemenu( $module_result.path, $module_result.node_id,                                     array('folder','info_page'), 1, 6 )}

{foreach $mainMenu as $menu}
  

{let node=fetch( 'content', 'node', hash( 'node_id', $menu.id ) )}
{$node.parent|attribute(show,1)}
{/let}
 
{/foreach}

As David said, that's going to slow the pages quite a bit.

http://www.sydesy.com

Bertrand Dunogier

Friday 05 August 2005 12:20:01 pm

Yes, I had noticed the same thing with the tree operator.

Anyway, as Xavier said, you can fetch in the usual way the node to get its ID.

Regarding the performances issue, I suggest that you use cache blocks in a clever way, and it should work like a charm...

Philip K.

Monday 17 October 2005 1:36:07 am

You can get the ID of the parent by using

{$node.parent.node_id}

I had the same problem and it works :)

Linux is like a wigwam; no windows, now gates, and apache inside!

eZ debug

Timing: Jan 21 2025 15:54:52
Script start
Timing: Jan 21 2025 15:54:52
Module start 'content'
Timing: Jan 21 2025 15:54:53
Module end 'content'
Timing: Jan 21 2025 15:54:53
Script end

Main resources:

Total runtime0.1828 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.0059 587.7109180.8359
Module start 'content' 0.00590.0107 768.5469101.9922
Module end 'content' 0.01660.1662 870.5391529.8984
Script end 0.1827  1,400.4375 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00402.1902200.0002
Check MTime0.00170.9334200.0001
Mysql Total
Database connection0.00070.366610.0007
Mysqli_queries0.121366.36071410.0009
Looping result0.00150.80381390.0000
Template Total0.165790.610.1657
Template load0.00120.681610.0012
Template processing0.164489.955310.1644
Override
Cache load0.00100.541510.0010
Sytem overhead
Fetch class attribute can translate value0.00110.592410.0011
XML
Image XML parsing0.00030.180010.0003
General
dbfile0.01437.8333200.0007
String conversion0.00000.003830.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.0002 secs