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!

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

Main resources:

Total runtime0.7761 sec
Peak memory usage4,096.0000 KB
Database Queries83

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0055 590.2734152.6250
Module start 'layout' 0.00550.0024 742.898439.4453
Module start 'content' 0.00790.7668 782.3438737.5156
Module end 'content' 0.77470.0013 1,519.859416.1641
Script end 0.7760  1,536.0234 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00340.4319160.0002
Check MTime0.00140.1766160.0001
Mysql Total
Database connection0.00090.114010.0009
Mysqli_queries0.701190.3331830.0084
Looping result0.00100.1263810.0000
Template Total0.742595.720.3712
Template load0.00220.278620.0011
Template processing0.740395.387620.3701
Template load and register function0.00020.026510.0002
states
state_id_array0.00080.101110.0008
state_identifier_array0.00080.105720.0004
Override
Cache load0.00190.2455400.0000
Sytem overhead
Fetch class attribute can translate value0.00060.083060.0001
Fetch class attribute name0.00100.1339110.0001
XML
Image XML parsing0.00300.386160.0005
class_abstraction
Instantiating content class attribute0.00000.0033120.0000
General
dbfile0.00300.3841220.0001
String conversion0.00000.001040.0000
Note: percentages do not add up to 100% because some accumulators overlap

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

Time used to render debug report: 0.0001 secs