Class CMenu
CMenu displays a multi-level menu using nested HTML lists.
The main property of CMenu is CMenu::$items
, which specifies the possible
items in the menu. A menu item has three main properties: visible, active and
items. The "visible" property specifies whether the menu item is currently
visible. The "active" property specifies whether the menu item is currently
selected. And the "items" property specifies the child menu items.
The following example shows how to use CMenu:
$this->widget('zii.widgets.CMenu', array( 'items'=>array( // Important: you need to specify url as 'controller/action', // not just as 'controller' even if default action is used. array('label'=>'Home', 'url'=>array('site/index')), // 'Products' menu item will be selected no matter which tag parameter value is since it's not specified. array('label'=>'Products', 'url'=>array('product/index'), 'items'=>array( array('label'=>'New Arrivals', 'url'=>array('product/new', 'tag'=>'new')), array('label'=>'Most Popular', 'url'=>array('product/index', 'tag'=>'popular')), )), array('label'=>'Login', 'url'=>array('site/login'), 'visible'=>Yii::app()->user->isGuest), ), ));
- CComponent
- CBaseController
- CWidget
- CMenu
Copyright: 2008-2013 Yii Software LLC
License: http://www.yiiframework.com/license/
Author: Jonah Turnquist <poppitypop@gmail.com>
Author: Qiang Xue <qiang.xue@gmail.com>
Since: 1.1
Located at x2engine/framework/zii/widgets/CMenu.php
public
|
#
init( )
Initializes the menu widget. This method mainly normalizes the |
public
|
|
protected
|
|
protected
|
|
protected
string
|
#
renderMenuItem( array $item )
Renders the content of a menu item. Note that the container and the sub-menus are not rendered here. |
protected
array
|
#
normalizeItems( array $items, string $route, boolean & $active )
Normalizes the |
protected
boolean
|
#
isItemActive( array $item, string $route )
Checks whether a menu item is active. This is done by checking if the currently requested URL is generated by the 'url' option of the menu item. Note that the GET parameters not specified in the 'url' option will be ignored. |
__construct(),
actions(),
getController(),
getId(),
getOwner(),
getViewFile(),
getViewPath(),
render(),
setId()
|
beginCache(),
beginClip(),
beginContent(),
beginWidget(),
createWidget(),
endCache(),
endClip(),
endContent(),
endWidget(),
renderFile(),
renderInternal(),
widget()
|
public
array
|
$items | array() |
#
list of menu items. Each menu item is specified as an array of name-value pairs.
Possible option names include the following:
|
public
string
|
$itemTemplate |
|
#
the template used to render an individual menu item. In this template, the token "{menu}" will be replaced with the corresponding menu link or text. If this property is not set, each menu will be rendered without any decoration. This property will be overridden by the 'template' option set in individual menu items via {@items}. |
public
boolean
|
$encodeLabel | true |
#
whether the labels for menu items should be HTML-encoded. Defaults to true. |
public
string
|
$activeCssClass | 'active' |
#
the CSS class to be appended to the active menu item. Defaults to 'active'. If empty, the CSS class of menu items will not be changed. |
public
boolean
|
$activateItems | true |
#
whether to automatically activate items according to whether their route setting matches the currently requested route. Defaults to true. |
public
boolean
|
$activateParents | false |
#
whether to activate parent menu items when one of the corresponding child
menu items is active. The activated parent menu items will also have its CSS
classes appended with |
public
boolean
|
$hideEmptyItems | true |
#
whether to hide empty menu items. An empty menu item is one whose 'url' option is not set and which doesn't contain visible child menu items. Defaults to true. |
public
array
|
$htmlOptions | array() |
#
HTML attributes for the menu's root container tag |
public
array
|
$submenuHtmlOptions | array() |
#
HTML attributes for the submenu's container tag. |
public
string
|
$linkLabelWrapper |
|
#
the HTML element name that will be used to wrap the label of all menu links. For example, if this property is set as 'span', a menu item may be rendered as <li><a href="url"><span>label</span></a></li> This is useful when implementing menu items using the sliding window technique. Defaults to null, meaning no wrapper tag will be generated. |
public
array
|
$linkLabelWrapperHtmlOptions | array() |
#
HTML attributes for the links' wrap element specified in |
public
string
|
$firstItemCssClass |
|
#
the CSS class that will be assigned to the first item in the main menu or each submenu. Defaults to null, meaning no such CSS class will be assigned. |
public
string
|
$lastItemCssClass |
|
#
the CSS class that will be assigned to the last item in the main menu or each submenu. Defaults to null, meaning no such CSS class will be assigned. |
public
string
|
$itemCssClass |
|
#
the CSS class that will be assigned to every item. Defaults to null, meaning no such CSS class will be assigned. |
$actionPrefix,
$skin
|
$controller,
$id,
$owner,
$viewPath
|