Get the main parent node_id on a simplified tree menu

Get the main parent node_id on a simplified tree menu

Friday 24 September 2010 5:17:59 am - 3 replies

Modified on Friday 24 September 2010 5:21:35 am by Lo' F.

Author Message

Nathan Kelly

Monday 27 September 2010 11:03:12 pm

First you need to know the depth of the main parent node, then use $node.path_array to find that node ID. e.g. if the main parent node depth is 1 then use $node.path_array.1, this will return the node ID for the main parent.
Use {$node.path_array|attribute(show)} from one of your document nodes and you'll see something like this:
Attribute Type Value
0 integer 1
1 integer 2
2 integer 85
3 integer 80
4 integer 90
This is a fairly common practice for tree menus, sometimes you might have to use $module_result.path.1.node_id instead, this will depend on the context you are in, you might be in the pagelayout.tpl for example.
The method you are using can also work but to get the main parent you need to go up another level, i.e. $contentStructureTree.parent.parent.node_id but I'd suggest you use the path_array method because it doesn't have to fetch as many objects to get the same result.

Hope that helps.

Cheers
Nathan.

Pardon me while I burst into flames...

Lo' F.

Tuesday 28 September 2010 9:14:09 am

Nathan, thank you so much! Your explanation has really helped me having a much clearer vision of the things now.

From the simplified_treemenu/show_simplified_treemenu.tpl template, though having some trouble getting something out using path_array and since path_string seems to return instead the parent node I was looking for, I made it work this way..

{if $contentStructureTree.parent_node.node.path_string|contains("284")}..

I am a little in rush to have this working in a way or another, so for the time being, it gonna be alright.

But definitely I will look into this stuff again!

Thank you again!

loredanaebook.it

Nathan Kelly

Tuesday 28 September 2010 5:45:18 pm

No problem Lo, glad I have helped in some way.

Because I don't have an install running that uses the simplified tree menu template I can't quickly test this, if you can't access the path_array you should try dumping the variables with: {$contentStructureTree.parent_node.node|attribute(show)}

This will show you all of the available information of the node. If ever in doubt you should try dumping variables this way, it's usually the quickest way to find what you need.

Cheers
Nathan.

Pardon me while I burst into flames...

You must be logged in to post messages in this topic!

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.