Yii 1.1: menu

SMenu is a simple multilevel drop down menu widget
12 followers

This extension is a simple multilevel drop down menu widget based on the dropdown menu at http://www.leigeber.com/2008/11/drop-down-menu/

Resources

Documentation

The widget takes four parameters:
menuID:The Id of the generated menu
stylesheet:The stylesheet to use
delay:The delay of the drop down animations.The faster is 2.Default delay is 6.
menu:The menu parameter is an array of arrays.Each array represents a menu item and has the following parameters:
url - An associative array:

'url'=> array(
        'route'=>'/product/create' //The route of the url : controller/action
        'link'=>'products/viewList.php' //For a fixed or external link
        'params'=>array('id'=>5) //The parameters to pass to the url
        'htmlOptions'=>array('target'=>'_BLANK') //options to pass to the menu link tag
        )
    If url is blank
'url'= '' or 'url'=array()

a menu without a link will be created.
label - The text to display on the menu item

'label'=>'List of Products'

icon- The icon to display next to the label

'icon'=>'protected/images/icon.png'

disabled - Whether the link is disabled

'disabled'=>true

visible - Whether the menu is visible

'visible'=>false

If a menu item is not visible all of its' submenus are not visible too.

Example:

<?php
$this->widget('application.extensions.menu.SMenu',
array(
"menu"=>array(
  array("url"=>array(
               "route"=>"/product/create"),
               "label"=>"Sspiner",
          array("url"=>array(
                       "route"=>"/product/create"),
                       "label"=>"Create product",),
          array("url"=>array(
                      "route"=>"/product/list"),
                      "label"=>"Product List",),
          array("url"=>"",
                       "label"=>"View Products",
          array("url"=>array(
                       "route"=>"/product/show",
                       "params"=>array("id"=>3),
                       "htmlOptions"=>array("title"=>"title")),
                       "label"=>"Product 3"),
            array("url"=>array(
                         "route"=>"/product/show",
                         "params"=>array("id"=>4)),
                         "label"=>"Product 4",
                array("url"=>array(
                             "route"=>"/product/show",
                             "params"=>array("id"=>5)),
                             "label"=>"Product 5")))),
          array("url"=>array(
                       "route"=>"/event/create"),
                       "label"=>"Scalendar"),
          array("url"=>array(),
                       "label"=>"Admin",
              array("url"=>array(
                           "route"=>"/event/admin"),
                           "label"=>"Scalendar Admin"),
                  array("url"=>array(
                               "route"=>"/product/admin"),
                               "label"=>"Sspinner Admin"),
                  array("url"=>array(
                               "route"=>"/product/admin"),
                               "label"=>"Disabled Link",
                               "disabled"=>true)),
          array("url"=>array(),
                       "label"=>"Documentation",
              array("url"=>array(
                           "link"=>"http://www.yiiframework.com",
                           "htmlOptions"=>array("target"=>"_BLANK")),
                           "label"=>"Yii Framework"),
              array("url"=>array(
                           "route"=>"site/spinnerDoc"),
                           "label"=>"Sspinner"),
              array("url"=>array(
                           "route"=>"site/calendarDoc"),
                           "label"=>"Scalendar"),
              array("url"=>array(
                           "route"=>"site/menuDoc"),
                           "label"=>"Smenu"),
                )
          ),
"stylesheet"=>"menu_blue.css",
"menuID"=>"myMenu",
"delay"=>3
)
);
?>

Check the homepage for more dosumentation

Change Log

July 15, 2009

  • Version 1.0.4

Changes:
(bug fix)Handling of undefined variables

July 3, 2009

  • Version 1.0.3

Changes:
Fixed a bug with url creation

June 11, 2009

  • Version 1.0.2

Changes:
Added an icon property in the menus.

June 4, 2009

  • Version 1.0.1

Changes:
1.Added a 4th parameter "delay" that controls the delay of the animation. Faster animation is delay = 2. Default delay is 6.

2.The url array now is a associative one with the following keys:
route (the yii route of the link : controller/action)
link (for a fixed or external link)
params (the GET parameters to pass to the url)
htmlOptions (the html options of the menu link tag)

June 2, 2009

  • Initial release.

Total 5 comments

#6668 report it
Ivan Wilhelm at 2012/01/27 09:26am
Perfect

This is a perfect extension for menu. Thanks!!

#5026 report it
Morthor at 2011/09/07 10:35am
Uninitialized string offset: 0

/opt/lampp/htdocs/stockcontrol2/protected/extensions/menu/SMenu.php(174)

174 isset($data["url"]["params"]) ? $params = $data["url"]["params"] : $params = array();

Got this error right out of the box with the example code from this page.

#3869 report it
zwobbel at 2011/05/16 07:14am
Good job

Thanks, looks good and very well documented :-)

#2141 report it
Trejder at 2010/11/17 07:07am
Looks very nice!

Needs some fix-ups - especially included CSS file makes this menu look a little shocking at first sight. But after all, this is the best, most flexible menu for Yii I found until now. Good job!

#52 report it
tax14 at 2010/10/03 02:24pm
SMENU

I like it. I have used it in two projects.

Leave a comment

Please to leave your comment.

Create extension