We are going to deploy the new yiiframework.com website on March 23, 2018 from 8:00 to 12:00 UTC.
Website and Yii documentation will not be available in this time frame. Check the news for more details.

Yii 1.1: mbmenu

MbMenu dropdown menu

MbMenu is an extension to CMenu wich provides you a nice dropdown menu.




  • Yii 1.0 or above
  • Tested on IE6/IE7/IE8/Firefox/Chrome


  • Extract the 'mbmenu' folder under protected/extensions


The usage of this extension is allmost the same like CMenu.

The following example shows how to use MbMenu:

<?php $this->widget('application.extensions.mbmenu.MbMenu',array(
                array('label'=>'Home', 'url'=>array('/site/index')),
                array('label'=>'Contact', 'url'=>array('/site/contact'),
                    array('label'=>'sub 1 contact'),
                    array('label'=>'sub 2 contact'),
                    array('label'=>'Sub 1', 'url'=>array('/site/page','view'=>'sub1')),
                    array('label'=>'Sub 2',
                        array('label'=>'Sub sub 1', 'url'=>array('/site/page','view'=>'subsub1')),
                        array('label'=>'Sub sub 2', 'url'=>array('/site/page','view'=>'subsub2')),
    )); ?>


<div id="mainmenu">


<div id="mainMbMenu">

to avoid conflicts with the standard CSS for the menu.

Change Log

January 23, 2012

  • v1.3 fix mentioned by Zyphers in function normalizeItems

February 23, 2010

  • v1.2 fix for IE7

February 22, 2010

  • v1.1 minor update in creation of class styles

February 18, 2010

  • Initial release.

Total 20 comments

#19530 report it
Lux69 at 2015/08/25 03:50am

Hi, i have this situation: I build my MBMenu dynamically, creating links like that:


In the SiteController then I catch this actions "Whatever-I-want" with missingAction($actionId), and later on do some work and display some data!

I noticed that only menu items, that have a NOT missingAction defined (for the action) show "Active" classes for the menu root items.

Can this somehow be fixed?? Regards Luka

#19293 report it
PHP Senior Developer at 2015/05/13 01:35am
Nice extension.

I am using Yii for the first time. I am having a dozens of menus in the menu bar and was stuck with how to keep them in navigation strip. This extension has solved my problem with its easy to understand parent-child relationship of menu items.

Good job, good documentation, simplicity to use.

#18087 report it
Jim K at 2014/09/05 04:11pm
updating css for mobile theme

For my mobile theme on my app, space is at a premium. I'd like to remove the empty padding space on the left side of the menu bar but I'm not quite sure what to change in the css. Any help?

I think it could be on the first line of the mbmenu.css: " padding:0 30px; "

Does this add a 30px padding around all the menu labels?


#16559 report it
Jim K at 2014/03/05 04:13pm
CSS & Color changes

@kiran & @Kradam:

In order to change the colors you must modify source/nav1_bg.gif and source/nav1_active.gif which provide the background and active selection colors. You can actually make this look nicer if you switch them to clean png files with gradients or some some such instead of the gif. If you do this you need to update the mbmenu.css file - just to a find/replace, no other edits are needed.

Activating the CSS: In order make the mbmenu.css active and not conflict with the default Yii css (blueprint), you need to update main.php as:

    <div id="mainmenu">
        <?php $this->widget('zii.widgets.CMenu',array(
    <div id="mainMbMenu">
        <?php $this->widget('application.extensions.mbmenu.MbMenu',array(
#16108 report it
jcagentzero at 2014/01/21 01:11am
The first menu I used!

Great extension and easy to learn, I remember the days when I am only guessing.

#15828 report it
noorr_swati at 2013/12/20 07:53am
visible is not working

visible is not working with the links that have children what i do?

#13911 report it
kradam at 2013/07/05 08:02am
Yii standard CSS

Does anyone modified mbmenu CSS to fit the style that comes with yii? IMHO there is clash of colors between mbmenu orange an yellow clash and yii blue gradients.

#11871 report it
ItsYii at 2013/02/10 04:44am
Active/Current selected Image

Hi I'm trying to have a different image depending on the page I'm on (like an active or current link). Here is my code.

array('label'=>'<img src="'.Yii::app()->request->baseUrl.'/images/products.gif" />', 'url'=>array('/category/index'),
                  'items'=>$items, 'active'=>'<img src="'.Yii::app()->request->baseUrl.'/images/products-on.gif" />'

'active'=> This doesn't have any effect.

Also is there a hover feature for images too


#11044 report it
kiran sharma at 2012/12/12 03:52am

try after removing assets files under projectFolder/assets/*

#11043 report it
mr.shadoww at 2012/12/12 03:46am

@kiran sharma at protected\extensions\mbmenu\source folder..i change the nav1_active1.gif file, it suppose to be change the color of the menu, but it don't, and you know what? even all file at protected\extensions\mbmenu\source folder i deleted and let the ..\source folder empty it's still give me the same menu layout...:( have you try to vanished file in the ..\source folder??

#11028 report it
kiran sharma at 2012/12/11 04:00am

i had use this extension much time before. and as i know menu background is generated by image(s), so to change background color you had to replace that image(s). you can found that images and their path by inspect element.

#11027 report it
mr.shadoww at 2012/12/11 03:53am
how to change menu background color

seriously i can't change or modify the menu style, event all asset in protected\extensions\mbmenu\source i deleted it still not effect.

#10185 report it
brunocalado at 2012/10/09 10:51am
Customize MBMenu CSS

I'm having trouble to change the style. How can I do it?

#9366 report it
ItsYii at 2012/08/07 05:35am
Generate Model drop down

How can I make the drop down list automatically gather all my models, is it possible with this extension? So for example if I click on one of my Menu items "Products" I want all the products model to show on the drop dow.


#8208 report it
Solleon at 2012/05/17 03:00pm

Very nice extension! Awesome!

#6938 report it
bilijen at 2012/02/14 05:16pm
Works out of the box

Great extension, thank you!

#6598 report it
zyphers at 2012/01/20 04:18am
hideEmptyItems property doesn't work

As CMenu's hideEmptyItems property is a bug according to issue 3029. And it's already fix in Yii's 1.1.9 as MbMenu bases on CMenu and has override a function normalizeItems so it should be fixed too.

#6052 report it
Alexandre Sena Coelho at 2011/12/08 05:40am
Very nice extension

It's useful for me. Great job!

#5998 report it
javed alam at 2011/12/04 06:37am
Ajax links

How can we use Ajax links.

#5950 report it
Fixticks at 2011/11/28 01:14pm
Important instructions, thanks nafa

Why isnt this part of the installation instructions. change div id = "mainmenu"> to.. div id = "mainMbMenu">

in protected/views/layouts/main.php

Leave a comment

Please to leave your comment.

Create extension
  • Yii Version: 1.1
  • License: New BSD License
  • Developed by: heyhoo
  • Category: User Interface
  • Votes: +89 / -1
  • Downloaded: 23,418 times
  • Created on: Feb 18, 2010
  • Last updated: Oct 9, 2012