Forums / Setup & design / Finding the 'top but one' node id

Finding the 'top but one' node id

Author Message

Ben Pirt

Saturday 12 July 2003 6:23:15 am

Hello all,
I have created a subnavigation element which will get all of the child nodes to the one which you are currently viewing.
What I would like to do is if the user is further down in the site, they will be shown the second level of navigation in that section.
e.g.

root
------ products
------ ------ red
------ ------ blue
------ ------ green
------ ------ ------ furry
------ ------ ------ smooth
------ contact
------ etc....

so when they are in:
products >> green >> furry

(or anywhere in the products section for that matter)

the subnavigation will show:
red
blue
green

hope this makes sense. The code I am currently using is:

subnav

{let folder_list=fetch( content, list, hash(parent_node_id, $node.node_id,sort_by, array( array( priority ))))}

<ul>

{section name=Folder loop=$folder_list}
<li><a href={concat("/",$Folder:item.url_alias)|ezroot}>{$Folder:item.name|wash}</a></li>

{/section}
</ul>

I am using the nice url technique (thanks Karsten), hence ezroot - The variable I need to replace is $node.node_id with the node_id for the top but one node (in this case products). Because I don't know how many levels deep the site will be, I can't just refer to the grandparent node. Any ideas?

Thanks in advance,
Ben Pirt

Paulo Almeida

Saturday 12 July 2003 6:44:30 am

If i understand your needs, I seen 2 ways (if anyone have another i'll thanks to seen it too)
You dont know the deep o site, but you know the level of top of your subnavigation. why don't use path too find the top level? something like this:
fetch('content','list',hash(parent_node_id,$module_result.path[2].node_id))

The other ir create an ini file, define there the id of top subnavigation and use ezini in template. or define directly in template (i really don't like this solution).

Hope helped

Paulo Almeida

PACPI.COM Internet Consulting
http://pacpi.com

Ben Pirt

Sunday 13 July 2003 5:06:34 am

i'll try the path version
thanks for your help,
Ben

Ibrahim Khachab

Friday 25 July 2003 4:27:52 am

I think that $node.path_array is an array of the parent nodes ids of the actual node. $node.path_array[0] if the id of root of the site $node.path_array[1] is the id of main folder.

You may use the following code to do what you are asking for.

{section name=parent_path offset=1 loop=$node.path_array}
{let parent_node=fetch('content',node,hash(node_id,$parent_path:item))}
{$parent_path:parent_node.name} >>
{/let}
{/section}

eZ debug

Timing: Jan 30 2025 21:22:07
Script start
Timing: Jan 30 2025 21:22:07
Module start 'content'
Timing: Jan 30 2025 21:22:07
Module end 'content'
Timing: Jan 30 2025 21:22:07
Script end

Main resources:

Total runtime0.3356 sec
Peak memory usage8,192.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0089 587.9453370.2969
Module start 'content' 0.00890.0131 958.24221,005.5313
Module end 'content' 0.02200.3135 1,963.77343,896.9922
Script end 0.3355  5,860.7656 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00461.3773200.0002
Check MTime0.00140.4189200.0001
Mysql Total
Database connection0.00050.158910.0005
Mysqli_queries0.237570.77391410.0017
Looping result0.00150.46101390.0000
Template Total0.313193.310.3131
Template load0.00090.255110.0009
Template processing0.312293.043310.3122
Override
Cache load0.00060.192210.0006
Sytem overhead
Fetch class attribute can translate value0.00280.821510.0028
XML
Image XML parsing0.00030.090910.0003
General
dbfile0.00782.3304200.0004
String conversion0.00000.002430.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