After introducing the YII database interface, introduce the ZII components from this article, including the list view ListView, the Table View GridView, and also some jquery based UI components, such as Autocomplete,datapicker, Button, Drag and drop and so on.
This article describes the menu usage, CMenu uses an HTML list to display multilevel menus, and the menu configuration is configured with its property item, which includes three primary properties
Visible is visible
Whether the active current menu item is selected,
Items submenu items.
In addition, the following properties are included:
URL: Optional, click on the URL link to the menu to go
Template: Optional, Menu Template
Linkoptions:array, optional, extra HTML link properties
Itemoptions:array, optional, extra HTML attribute to display menu items.
Submenuoptions:array, optional, extra display of the submenu's HTML properties.
You can generally define the menu in the layout layout, such as this example, to modify the protected/views/layout/main.php
<?php
$this->widget (' Zii.widgets.CMenu ', Array (
' Items ' =>array ('
label ' => ' home '),
' url ' =>array ('/site/index '),
Array (' label ' => ' about ',
' url ' =>array ('/site/page ',
' View ' => ')),
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, the default directory for static pages is the pages subdirectory under the current Controller view directory, in this case, two static pages are created in the pages directory about.php, contact.
To use Cviewaction to display a static page, you need to modify the controller's actions method:
Public function actions ()
{return
array ('
page ' =>array ('
class ' => ' Cviewaction '
)
);
}
In addition, if you want to show the menu's hierarchical trajectory (breadcrumbs), you can use the Cbreadcrumbs component in the Zii component, cbreadcrumbs generally with CMenu
<?php if (isset ($this->breadcrumbs)):?>
<?php $this->widget (' Zii.widgets.CBreadcrumbs ', Array (
' links ' => $this->breadcrumbs,
)); ?><!--breadcrumbs-->
<?php endif?>
This example uses Yii's default CSS to display the results as follows:
If you do not use CSS, the results appear as follows:
This shows that you need to use the CMenu component together with the appropriate CSS to display a beautiful menu.
This example downloads: Http://www.imobilebbs.com/download/yii/MenuDemo.zip
See a full set of tutorials: http://www.bianceng.cn/webkf/PHP/201301/35265.htm