Property |
Type |
Description |
|
$activateItems |
|
whether to automatically activate items according to whether their route setting
matches the currently requested route. |
|
$activateParents |
|
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 [[activeCssClass]]. |
|
$activeCssClass |
|
the CSS class to be appended to the active menu item. |
|
$encodeLabels |
|
whether the labels for menu items should be HTML-encoded. |
|
$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. |
|
$hideEmptyItems |
|
whether to hide empty menu items. An empty menu item is one whose url option is not
set and which has no visible child menu items. |
|
$itemOptions |
|
list of HTML attributes shared by all menu [[items]]. If any individual menu item
specifies its options, it will be merged with this property before being used to generate the HTML
attributes for the menu item tag. The following special options are recognized:
- tag: string, defaults to "li", the tag name of the item container tags.
Set to false to disable container tag.
See also [[\yii\helpers\Html::tag()]]. |
|
$items |
|
list of menu items. Each menu item should be an array of the following structure:
- label: string, optional, specifies the menu item label. When [[encodeLabels]] is true, the label
will be HTML-encoded. If the label is not specified, an empty string will be used.
- encode: boolean, optional, whether this items label should be HTML-encoded. This param will override
global [[encodeLabels]] param.
- url: string or array, optional, specifies the URL of the menu item. It will be processed by [[Url::to]].
When this is set, the actual menu item content will be generated using [[linkTemplate]];
otherwise, [[labelTemplate]] will be used.
- visible: boolean, optional, whether this menu item is visible. Defaults to true.
- items: array, optional, specifies the sub-menu items. Its format is the same as the parent items.
- active: boolean, optional, whether this menu item is in active state (currently selected).
If a menu item is active, its CSS class will be appended with [[activeCssClass]].
If this option is not set, the menu item will be set active automatically when the current request
is triggered by url. For more details, please refer to Menu::isItemActive.
- template: string, optional, the template used to render the content of this menu item.
The token {url} will be replaced by the URL associated with this menu item,
and the token {label} will be replaced by the label of the menu item.
If this option is not set, [[linkTemplate]] or [[labelTemplate]] will be used instead.
- submenuTemplate: string, optional, the template used to render the list of sub-menus.
The token {items}` will be replaced with the rendered sub-menu items.
If this option is not set, [[submenuTemplate]] will be used instead.
- options: array, optional, the HTML attributes for the menu container tag. |
|
$labelTemplate |
|
the template used to render the body of a menu which is NOT a link.
In this template, the token {label} will be replaced with the label of the menu item.
This property will be overridden by the template option set in individual menu items via [[items]]. |
|
$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. |
|
$linkTemplate |
|
the template used to render the body of a menu which is a link.
In this template, the token {url} will be replaced with the corresponding link URL;
while {label} will be replaced with the link text.
This property will be overridden by the template option set in individual menu items via [[items]]. |
|
$options |
|
the HTML attributes for the menu's container tag. The following special options are recognized:
- tag: string, defaults to "ul", the tag name of the item container tags. Set to false to disable container tag.
See also [[\yii\helpers\Html::tag()]]. |
|
$params |
|
the parameters used to determine if a menu item is active or not.
If not set, it will use $_GET. |
|
$route |
|
the route used to determine if a menu item is active or not.
If not set, it will use the route of the current request. |
|
$submenuTemplate |
|
the template used to render a list of sub-menus.
In this template, the token {items} will be replaced with the rendered sub-menu items. |
|