[solved] second menu

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
DW
Forum Members
Forum Members
Posts: 15
Joined: Thu Dec 06, 2007 2:42 pm

[solved] second menu

Post by DW »

I have spend alot of time in the documentation and searching on this forum but only found "no answer answers" like "go read the manual!" or "you have to code it".. some helpfull users here  ::)..


anyway
the question as have been asked many times before is this


I have the menu like this

1
2
2.1
2.2
2.2.1
2.2.2
2.3
3
3.1
4
4.1
4.2

top menu is set to display only top menu
{menu template='Top' number_of_levels='1'}

submenu like this
{menu template='Sub' show_root_siblings='0' collapse='1' start_level='2'}


submenu is like this

Fler val

{foreach from=$nodelist item=node}
url}">{$node->menutext}
{/foreach}




Now.. you who understand this system better than me will probobly see what is wrong..
What I want is this
I click on menu 2
sub menu now display 2.1 and 2.2
if I click on 2.2, then sub menu display 2.2.1 and 2.2.2

but now it displays every sub menu under the top level..
so.. clicking on 2 or 2.1. or 2.2 or 2.2.1 or 2.2.2 always display 2.1, 2.2
how to I make it start on the current level and only display one step below?


[SOLUTION]

menutemplate for submenu

Code: Select all

{foreach from=$nodelist item=node}
{if $node->current==true}
{assign var="depth" value=$node->depth}
{/if}
{/foreach}

{foreach from=$nodelist item=node}
{if $node->depth==$depth+1}
{assign var="hassub" value=1}
{/if}
{/foreach}

{if $hassub==1 }
<li id="submeny">
<h2>Fler val</h2>
<ul>
{foreach from=$nodelist item=node}
{if $node->depth==$depth+1}
<li><a href="{$node->url}">{$node->menutext}</a></li>
{/if}
{/foreach}
</ul>
</li>
{/if}
what I do is,
look at all menues until current menu is found.
set that menues depth
look at all menues matching that depth
count number of menus to know if this should be displayed or not

Display menu in template

Code: Select all

{menu template='Sub' show_root_siblings='0' collapse='1' start_level='1'}
it works for me.. hope it can help someone
Last edited by DW on Thu Oct 02, 2008 1:31 am, edited 1 time in total.
Russ
Power Poster
Power Poster
Posts: 813
Joined: Fri Nov 25, 2005 5:02 pm
Location: North West England

Re: second menu

Post by Russ »

Unless I'm missing something, this is in the Help for the Menu Manager?

# (optional) start_page="home" - Starts the menu displaying at the given start_page and showing that element and it's children only. Takes a page alias.
# (optional) start_element="1.2" - Starts the menu displaying at the given start_element and showing that element and it's children only. Takes a hierarchy position (e.g. 5.1.2).
# (optional) start_level="2" - This option will have the menu only display items starting a the given level. An easy example would be if you had one menu on the page with number_of_levels='1'. Then as a second menu, you have start_level='2'. Now, your second menu will show items based on what is selected in the first menu.
# (optional) show_root_siblings="1" - This option only becomes useful if start_element or start_page are used. It basically will display the siblings along side of the selected start_page/element.
# (optional) show_all="0" - This option will cause the menu to show all nodes even if they are set to not show in the menu. It will still not display inactive pages however.
# (optional) number_of_levels="1" - This setting will only allow the menu to only display a certain number of levels deep.
# (optional) items="contact,home" - Use this item to select a list of pages that this menu should display. The value should be a list of page aliases separated with commas.
# (optional) collapse="1" - Turn on (set to 1) to have the menu hide items not related to the current selected page.
DW
Forum Members
Forum Members
Posts: 15
Joined: Thu Dec 06, 2007 2:42 pm

Re: second menu

Post by DW »

So basicly there is no way to set "start_page" = currently selected page?
How would I code this in the menutemplate then?
I don't know all the node-> attributes availible  :'(
but guess there should be some if(currentlyselected = node->parent) or something like that..
Russ
Power Poster
Power Poster
Posts: 813
Joined: Fri Nov 25, 2005 5:02 pm
Location: North West England

Re: [solved] second menu

Post by Russ »

Again, unless I'm very much mistaken, his works for me?
{cms_module module="menumanager" template="rbmenu-vert.tpl" start_level="2" collapse=1"}

There are no sub-sub menus on this site (but they work) - select the mobile style or remove style sheets and you will I think see what you want? (Sub menu is below main content if you choose to mobile/remove styles)

http://www.weddingsandportraitphotography.co.uk/
User avatar
chuckienorton
Forum Members
Forum Members
Posts: 68
Joined: Wed Feb 14, 2007 6:58 pm
Location: Pasadena, California

Re: [solved] second menu

Post by chuckienorton »

DW,

this is exactly what I was looking for... however - out of the box, this displays the words "Fler Val" as the root page of that menu. All children work perfectly. What I want is for th "Fler Val" to display the actual parent name of that sub menu automatically.  Any clue how to make that title dynamic?

Chuck
Post Reply

Return to “CMSMS Core”