Page 1 of 1

Print the parent level 0 above the vertical menu

Posted: Wed Mar 06, 2013 4:26 pm
by terael
Hi,

My first level is shown in a horizontal main menu with popup submenus to go to children :
Firt entry | Second Entry | Third Entry

Then I display a vertical contextual menu. I used the "Navigation: Simple - Vertical" menu and placed the code in my template :
"{$cgsimple->get_root_alias('', 'root_alias')}
Page parent : {$cgsimple->get_page_title($root_alias)}
{menu loadprops=0 template="MRI:simple_nav_gche" start_level='2' collapse='1'}"

If I choose a child (ie child 2) in the submenu of "Second Entry", the list of the children is printed on the vertical menu. It works ! Cool !

But I would like to print the "Parent" where I came from (with its link) too:

Second Entry
> child 1
> child 2
> child 3

After several hours of research, i could'nt find the way... Please... :'(

Re: Print the parent level 0 above the vertical menu

Posted: Wed Mar 06, 2013 6:19 pm
by Dr.CSS
Sounds like start_page='$root_alias'...

Re: Print the parent level 0 above the vertical menu

Posted: Wed Mar 06, 2013 8:06 pm
by terael
I found sthg !
Thanks to lessire.be who has a page about its Menu Manager.

Built the "hierarchy" UDT (user defined tag)

global $gCms;
$pos = $gCms->variables['position'];
$base = explode('.', $pos);
$totalDepth = count($base);
$parentDepth = $totalDepth;
$count = 0;

foreach($base as $parentLevel) {
$parentLevel = ltrim($parentLevel, "0" );
if($count <= $parentDepth) {
$thisLevel .= $parentLevel . ".";
}
if($count < $parentDepth) {
$theParent .= $parentLevel . ".";
}
$count++;
}

$smarty->assign('h_toplevel', $base[0] * 1);
$smarty->assign('h_parent', rtrim($theParent, "." ));
$smarty->assign('h_this', rtrim($thisLevel, "." ));

Re: Print the parent level 0 above the vertical menu

Posted: Sat Nov 02, 2013 1:38 pm
by clapczyn
*EDIT*
I'm an Idiot …
solved it with menumanager and a seperate template just right after I submitted this …
sorry!
*EDIT*



Hi terael,

that UDT is almost what I am looking for.
I've got a horizontal top menu (with dropdown) and in addition a vertical submenu (same as dropdown). Since I am using babel for multilingual content I've got 3 levels of pages like this:

1 Deutsch
1.1 Leistungsangebot
1.1.1 Financial Advisory
1.1.2 Rating Advisory
...

2 English
2.1 Range of services
2.1.1 Financial Advisory
2.1.2 Rating Advisory
...

Horizontal Menu call:

Code: Select all

{menu start_level="2" number_of_levels="2"}
Vertical submenu for a selected menupoint:

Code: Select all

{menu start_level="3" template="submenu"}
I now want the parent (level 2) of the selected submenupoint (level 3) to be shown as a headline in the vertical sidebar:

Code: Select all

<h1>Level 2 (Parent) Title</h1>
{menu start_level="3" template="submenu"}
Problem is that some level 2 elements have content, some are just internal sitelinks.

Your UDT returns the top-level value (1 or 2 for Deutsch or English) in h_toplevel
But unfortunately it always returns the same value for h_parent and h_this (the current page)

So when level 2 has content it returns for example 1.2 for both
If it is just a sitelink that calls the first child it returns the childs hierarchical position (for example: 1.2.1)

Maybe this is the wrong place for my question or maybe there is another better solution but this was the closest solution I could find in the forum … if so, sorry!

I hope that I've explained my problem good enough – any help is highly appreciated!

Thx in advance!

*EDIT*
I'm an Idiot …
solved it with menumanager and a seperate template just right after I submitted this …
sorry!
*EDIT*

Re: Print the parent level 0 above the vertical menu

Posted: Sat Nov 02, 2013 4:20 pm
by staartmees
Please add [solved] to the title