1 (edited by sammik2 2013-01-19 08:17:14)

Topic: Multilevel menu

First, thank you for very nice CMS.
I would like to know, how is possible to create multilevel menu.
I found topic, that it is not possible yet http://forum.monstra.org/topic/27/menu-drop-down/
but in monstrathemes.com it is done, so how it is at the moment?
Thank you.
(I am very new to monstra and php)

Re: Multilevel menu

This is not finally complite version of plugin as autor said from russian forum =DD

(с) Roman Art
So far So good wink

Re: Multilevel menu

Thank you, I will look on it. I see. I finnally have to learn azbuka.

Re: Multilevel menu

i made some small mods, to show a bootstrap dd-menu ...

tested against monstra 2.1.3, only one level is possible...

ddmenu-plugin.zip (11K)

5 (edited by glebcha 2013-02-26 11:50:16)

Re: Multilevel menu

antiben, is it possible to leave only parent with class='active', but not children? Now only children highlighted and not parent.

What I need is:

<<Menu item (highlited with css if active) // Parent (highlited with css if child active)  // Menu item (highlited with css if active) // Menu item (highlited with css if active) >>
                                                                            Child (without css highlight)

I guess I should edit this part:

            // get the default category
            if (trim($item['branch']) !== '') {

                if (trim($li_active) !== '') {
                    $li_active = ' class="active dropdown"';
                } else {
                    $li_active = ' class="dropdown"';

                if (trim($anchor_active) !== '') {
                    $anchor_active = ' class="current dropdown-toggle" data-toggle="dropdown" ';
                } else {
                    $anchor_active = ' class="dropdown-toggle" data-toggle="dropdown" ';

            if (trim($item['branch']) !== '') {
               echo '<li'.$li_active.'>'.'<a href="'.$link.'"'.$anchor_active.$target.'>'.$item['name'].'</a>';
               echo '<ul class="dropdown-menu">';
               echo Menu::get($item['branch']);
               echo '</ul></li>';
            } else {
               echo '<li'.$li_active.'>'.'<a href="'.$link.'"'.$anchor_active.$target.'>'.$item['name'].'</a>'.'</li>';

6 (edited by antiben 2013-02-26 17:19:21)

Re: Multilevel menu

mh, not quite sure what you mean...

Now only children highlighted and not parent.

a parent gets also active, see example below (reload the screenshot, now it's with a mouse pointer):

pages: name(slug)
-   pagetitle1(pageone)
 →  pagetitle2(pageone/pagetwo)
 →  pagetitle3(pageone/pagethree)

default menu: name(link,branch)

menutest menu: name(link,branch has to be empty - since only one level ...)

is it possible to leave only parent with class='active', but not children?

if you want to have only the parent active, try this mod (it's the part above the code you posted):

            $item['descripton'] = Html::toText($item['description']);

            $pos = strpos($item['link'], 'http://');
            if ($pos === false) {
                $link = Option::get('siteurl').$item['link'];
            } else {
                $link = $item['link'];

            if (isset($uri[0]) && $uri[0] !== '')  {
                if (in_array($item['link'], $uri) && trim($item['branch']) !== '') {
                    $anchor_active = ' class="current" ';
                    $li_active = ' class="active"';
            } else {
                if ($defpage == trim($item['link'])) {
                    $anchor_active = ' class="current" ';
                    $li_active = ' class="active"';

            if (trim($item['target']) !== '') {
                $target = ' target="'.$item['target'].'" ';

            // get the default category

7 (edited by antiben 2013-02-27 02:48:47)

Re: Multilevel menu

another confusing way could be:
pages: name(slug)[¹]

- maintitle1(mainpageone)
 →  pagetitle1(mainpage/pageone)
 →  pagetitle2(mainpage/pagetwo)

- maintitle2(mainpagetwo)
 →  pagetitle1(mainpagetwo/pageone)
 →  pagetitle2(mainpagetwo/pagetwo)

- maintitle3(mainpagethree)
 →  pagetitle1(mainpagethree/pageone)
 →  pagetitle2(mainpagethree/pagetwo)

default menu: name(link,branch)


ddmenutest menu: name(link,branch has to be empty - since one level only ...)


[¹] pseudo-pages - not possible at the time, see here

image with submenu:
download: ddmenu-2-plugin.zip (17K)
note: only tested against a default monstra 2.1.3 installation...

8 (edited by glebcha 2013-02-27 05:15:03)

Re: Multilevel menu

Your mod just disabled class active for all <li> elements smile

What I need is:

<li class="dropdown">
 <a href="http://localhost/site/" class="dropdown-toggle" data-toggle="dropdown">Parent</a>   <---------- need to assign class="mycustomclass" (a href="http://localhost/site/" class="mycustomclass) 
    <ul class="dropdown-menu">                                                                                                                                           
        <li class="active"><a href="http://localhost/site/child" class="current">Child1</a></li>
        <li><a href="http://localhost/site/child?tag=sometag">Child2</a></li>

Re: Multilevel menu

I need to ask, any one have plugin worked with 3.0.1?

Thank you