After introducing the Yii database interface, we introduce the Zii component from this chapter, including the List view ListView, the Tabular view of the GridView, and also include some jquery-based UI components such as Autocomplete,datapicker, Button, Drag and drop and so on.
This article describes the menu menu usage, CMenu uses an HTML list to display a multilevel menu, and the menu configuration is configured with its properties item, each of which includes three main attributes
Visible or invisible
Whether the active current menu item is selected,
Items Sub-menu items.
Also includes the following properties:
URL: Optional, click the menu to go to the URL link
Template: Optional, menu templates
Linkoptions:array, optional, additional HTML link properties
Itemoptions:array, optional, additional HTML attributes for displaying menu items.
Submenuoptions:array, optional, additional display of the submenu's HTML properties.
You can generally define menu in layout layouts, such as this example, to modify protected/views/layout/main.php
$this->widget (' Zii.widgets.CMenu ', Array (' Items ' =>array (' label ' = ' Home ', ' url ' =>array ('/site/ Index '), Array (' label ' = ' about ', ' url ' =>array ('/site/page ', ' view ' = ' about '), Array (' label ' = ') Contact ', ' url ' =>array ('/site/page ', ' view ' = ' contact '), Array (' label ' = ' Login ', ' url ' =>array ('/site/ Login '), ' visible ' =>false),);?>
This example uses Cviewaction to display several static pages, and the default directory for the static page is the pages subdirectory of the current controller's view directory, which in this case creates two static page about.php in the pages directory.
To use Cviewaction to display static pages, you need to modify the controller's actions method:
Public function actions () {return Array (' page ' =>array (' class ' = ' Cviewaction ',)});
In addition, if you want to display the menu's hierarchical trajectory (breadcrumbs), you can use the Cbreadcrumbs component in the Zii component, Cbreadcrumbs general mates CMenu Use
breadcrumbs)): >widget (' Zii.widgets.CBreadcrumbs ', Array (' links ' = $this->breadcrumbs,));?>
This example uses the Yii default CSS to display the results as follows:
If you do not use CSS, the results are as follows:
This shows that you need to use the CMenu component together with the appropriate CSS to display beautiful menus.
The above is the PHP Development Framework Yii Framework Tutorial (ZII) component-menu sample content, more relevant content please pay attention to topic.alibabacloud.com (www.php.cn)!