Yii 1.1: accordion-menu

Simple two level vertical accordion menu.
21 followers
  • Menu is displayed vertically
  • Toplevel items is a link
  • Accordion has indicators to show the state of the menu

Extension have a small size (near 18kb) but depends on jQuery.

Requirements

Yii 1.1.x or above

Usage

Crete menu items array

$items = array(
    array(
        'name' => 'Google corp',
        'link' => 'http://google.com',
        'icon' => 'google',
        'active' => 'dashboard',
        'sub' => array(
            array(
                'name' => 'Gmail',
                'link' => 'http://gmail.com',
            ),
            array(
                'name' => 'Gmap',
                'link' => 'http://maps.google.com/',
            )
        )
    )
);

Use menu widget:

$this->widget('ext.menu.EMenu', array('items' => $items));

Resources

Total 14 comments

#13594 report it
kazuyahiko at 2013/06/09 11:48pm
nice menu

hhmmm how to make the menu like skworden made using this extension

#13221 report it
Wildan Muhlis at 2013/05/15 06:48pm
Custom Icon from link

Is there any parameter to change custom icon from a link?

Thanks,

#12026 report it
Nikolay I. Belichuk at 2013/02/21 03:38am
to jmariani

how to keep the parent item of a clicked subitem expanded.

Can you provide more information about this behavior?

#12020 report it
jmariani at 2013/02/20 05:27pm
Keep open selected item

Hi.

Nice extension I have to say. Congrats.

What I want to know is how to keep the parent item of a clicked subitem expanded.

Any idea?

#11850 report it
Nikolay I. Belichuk at 2013/02/07 10:59am
Version 1.1

Extension support module check, so you can use

'active' => 'user/module/index'

And everything will be fine

#11786 report it
bardoo at 2013/02/04 03:48am
resolving Error loading EMenu.php

for thoes who had a problem when adding this extension, you may edit the "EMenu.php" by adding

<?php

on the top.

#11765 report it
Alegbe Bamidele at 2013/02/02 07:01am
i am having error

Fatal error: Class 'EMenu' not found in C:\xampp\htdocs\yii\framework\web\CWidgetFactory.php on line 147

#11487 report it
skworden at 2013/01/16 10:34am
RE: Nikolay I. Belichuk

Is there a way you could make it so active = any of the URLs that are in the top and sub menus? That way your sub menu items could be anything and not stuck to the one controller if you want it to be active.

I kinda get what your saying but I'm still not understanding completly.

I couldn't get your method to work at all. This module uses so many different controllers and I don't know a way to get it to work for say /user/profilefield or /user/profilefield/create.

What would I put in the active class for this to register? If I put user in the active class it will expand if you go to mydomain.com/user/user however, not on anything other than that.

here is what I'm using.

array(
      'name' => 'Users',
      'link' => array('/user/user'), //it won't be active with just /user/ or user/index
      'icon' => 'user',
      'active' => 'user',
      'sub' => array(
          array(
          'name' => 'List Users',
          'link' => array('/user/user'),//Only link that will register as active
                  'icon' => 'th-list',
          ),
           array(
          'name' => 'Add User',
          'link' => array('/user/admin/create'),//dosen't register as active
                  'icon' => 'plus-sign',
          ),
          array(
          'name' => 'Edit Users',
          'link' => array('/user/admin'),//dosen't register as active
                  'icon' => 'pencil',
          ),
              array(
          'name' => 'List User Fields',
          'link' => array('/user/profilefield'),//dosen't register as active
                  'icon' => 'list-alt',
          ),
              array(
          'name' => 'Edit User Profile Fields',
          'link' => array('/user/profileField/admin'),//dosen't register as active
                  'icon' => 'plus-sign',
          ),
                array(
          'name' => 'Add User Profile Field',
          'link' => array('/user/profileField/create'),//dosen't register as active
                  'icon' => 'edit',
          ),
      )
      ),
#11472 report it
Nikolay I. Belichuk at 2013/01/15 12:41pm
Re: isn't working with yii-user

To skworden at 2013/01/11 12:45pm (#11409) As I know yii-user is extension. I Also use own user extension in my app, so I write :

/user/module/index

where - user: extesion name - module: controller name - index: action name

#11471 report it
staticblue at 2013/01/15 11:57am
Hovering ?

Hello,

How would you modify the menu to open up when hovered instead of clicked ?

Thanks, Jonathan

#11409 report it
skworden at 2013/01/11 12:45pm
Active

Edit: just isn't working with yii-user

Active doesn't work if it's a module's controller.

i.e. I'm using user module so the url is mydomain/user. I put user in the active class like this:

array(
      'name' => 'Users',
      'link' => array('/user'),
      'icon' => 'user',
      'active' => 'user',
      'sub' => array(
              .......

and it doesn't register it as being active when on mydomain/user.

#11387 report it
skworden at 2013/01/10 09:48am
Add Icon to Second Level

I don't know if there is a better way to do this but this is what i did to have 2nd level icons.

in emenu.php:

After

if( $level == 1 ){
    ...content
}

Add

if( $level == 2 ){
    $icon_class = isset($item['icon']) ? $item['icon'] : 'none';
    $icon_class = 'menu_icon ' . 'icon-' . $icon_class;
    $icon   = CHtml::tag('span', array('class'=> $icon_class), '');
    $toggleOptions = array(
        'class' => $toggleclass
    );
    $toggleContent = $icon . $content;
    $content  = $toggleContent;
}

You can call it just like you do on level one with 'icon'=>'icon',.

array(
      'name' => 'Assets',
      'link' => array('/assets/index'),
      'icon' => 'barcode',
      'active' => 'assets',
      'sub' => array(
          array(
          'name' => 'List Assets',
          'link' => array('/assets/index'),
          'icon' => 'th-list',
          ),
      )
      ),

#11040 report it
Nikolay I. Belichuk at 2012/12/11 05:33pm
RE: AustinGeek

You gave me idea, I'll think about it on weekend

#11039 report it
AustinGeek at 2012/12/11 02:02pm
Nice Menu !

Seems well behaved.

Have you done any integration with mysql db? I think it would be easy to format the structure, just curious if you had done so and had any advice or suggestions on what to do/avoid.

Thanks!

Leave a comment

Please to leave your comment.

Create extension