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/
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:
$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
Changes:
(bug fix)Handling of undefined variables
Changes:
Fixed a bug with url creation
Changes:
Added an icon property in the menus.
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)
Total 5 comments
This is a perfect extension for menu. Thanks!!
/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.
Thanks, looks good and very well documented :-)
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!
I like it. I have used it in two projects.
Leave a comment
Please login to leave your comment.