Page 1 of 1

Show submenu only for active item

Posted: Tue Aug 20, 2013 12:35 pm
by Reanimator
Hi!
I need to display a menu where the submenu is displayed only in the active item.

Here's an example:

Code: Select all

Menu 1
Active Menu 2
  Submenu 1
  Submenu 2
  Submenu 3
Menu 3
However other items may also have submenus, but since these items are not active, there submenus must be hidden.

And, if you select any item from the submenu, then the corresponding branch should be opened.

Here's an example:

Code: Select all

Menu 1
Menu 2
  Submenu 1
  Active submenu 2
  Submenu 3
Menu 3
And so, too:

Code: Select all

Menu 1
Menu 2
  Submenu 1
  Submenu 2
    Subsubmenu 1
    Active subsubmenu 2
    Subsubmenu 3
  Submenu 3
Menu 3

Re: Show submenu only for active item

Posted: Tue Aug 20, 2013 12:42 pm
by velden
It's often called an 'accordion menu' (Google for that) and maybe it's even in CMSMS by default (not sure, I don't use the default templates).

The cmsms docs use it too: http://docs.cmsmadesimple.org/installat ... nformation

Re: Show submenu only for active item

Posted: Tue Aug 20, 2013 1:59 pm
by uniqu3
There is "collapse" parameter for MenuManager so setting {menu collapse='1'} will show children only when you are currently on parent or child page.

From module help:
collapse="1" - Turn on (set to 1) to have the menu hide items not related to the current selected page.

Re: Show submenu only for active item

Posted: Tue Aug 20, 2013 10:19 pm
by Dr.CSS

Re: Show submenu only for active item

Posted: Wed Aug 21, 2013 6:29 am
by Reanimator
It works when i put this tag {menu collapse="1"}, but it does not work when i add childrenof="some_menu" param (like this {menu childrenof="som_menu" collapse="1"}.

Hm...It is strange...

Re: Show submenu only for active item

Posted: Wed Aug 21, 2013 11:20 am
by uniqu3
childrenof does exactly what it says, it shows children of specified page, it's a feature.
childrenof="" - This option will have the menu only display items that are descendants of the selected page id or alias. i.e: {menu childrenof=$page_alias} will only display the children of the current page.
Please read Module Help, you can find it in backend, for example when in ModuleManager click on "Module Help" on the right top side before assuming something is supposed to work the way you think but it wasn't inteded to work how you think :) .

Re: Show submenu only for active item

Posted: Thu Aug 22, 2013 2:12 pm
by Reanimator
Thank you. I'm not stupid. I understand how the parameter childrenof works. The problem is that I need simultaneously display the "selected" sub-menu(use param childrenof) with hidden child nodes of inactive nodes(use param collapse).
I hope I have clearly explained.

I thought that it is possible to combine these two options and get the needed result.

Re: Show submenu only for active item

Posted: Thu Aug 22, 2013 2:59 pm
by velden
Isn't this a css and/or javascript issue rather than a Menu Manager issue?

Re: Show submenu only for active item

Posted: Wed Aug 28, 2013 6:07 am
by Reanimator
No. It isn't css or js issue...

Re: Show submenu only for active item

Posted: Wed Aug 28, 2013 4:35 pm
by Dr.CSS
http://multiintech.com/defaultcontent/d ... _left.html

{menu start_level='2' collapse='1'}

Will show any children of the page you are on, if no children under that page it will show nothing...

Reading the default content can go a long way in explaining how CMSMS works...

Re: Show submenu only for active item

Posted: Fri Aug 30, 2013 11:13 am
by Reanimator
The problem is solved. I solved this by CSS.

But no one knew what I wanted.

I have 3 sites on the same CMS. Menu of each site is located in a separate folder (content type: section header).

Here are the sites:
1. http://server.w3bmaster.ru/beratungsser ... anzierung/
2. http://server.w3bmaster.ru/beratungsser ... sicherung/
3. http://server.w3bmaster.ru/beratungsser ... ents-life/

Each site has its own template. In each template there is a tag like this: {menu childrenof="alias"}

I can't use params start level or another, because I need to show in each template its own menu.

So, this tag( {menu childrenof="alias"}) inserts a menu with all its items.

My problem was simple. Show the first level and second level ONLY FOR CURRENTLY active item (if second level exist).

So, I find in "module help" that parameter "collapse" solves this poblem. But when I added to the one template this tag({menu childrenof="alias" collapse="1"}) i saw the same situation. I saw menu with all items and subitems.(first level, second etc).
Param "collapse" works if I put in the template this tag: {menu collapse="1"}, but it doesn't work when i add param "childrenof".

Now I see, that active item has class "menuactive", so I solved it with CSS:
Code:
.menu .parent ul{
display:none;
}

.menu .parent.menuactive ul{
display:block;
}

But "hidden" items are still in HTML code. It is not neccesary now for me, but I would like to do it on the server side.