After introducing the Yii database interface, we will start with this article to introduce Zii components, including list view ListView, table view GridView, and some UI components based on JQuery, such as AutoComplete, DataPicker, Button, Drag and Drop, etc.
This article introduces the usage of Menu menu. CMenu uses Html list to display multi-level menus. Menu configuration is configured through its attribute item. Each menu item includes three main attributes
visible Is it visible
active Whether the current menu item is selected,
items submenu items.
In addition, the following attributes are included:
label: optional, menu name, supports HTML tags.
url: Optional, click on the URL link in this menu
template: optional, menu template www.2cto.com
linkOptions: array, optional, additional HTML link attributes
itemOptions: array, optional, additional HTML attributes for displaying menu items.
submenuOptions: array, optional, additionally displays the HTML attributes of the submenu.
Generally, Menu can be defined in Layout. For example, in this example, modify protected/views/layout/main.php
widget('zii.widgets.CMenu',array(
'items'=>array(
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. The default directory of static pages is the pages subdirectory under the current Controller's View directory. This example creates two static pages about.php and contact in the pages directory.
To use CViewAction to display static pages, you need to modify the Actions method of the Controller:
public function actions()
{
return array(
'page'=>array(
'class'=>'CViewAction',
)
);
}
In addition, if you want to display the hierarchical trajectory (breadcrumbs) of the menu, you can use the CBreadcrumbs component in the Zii component. CBreadcrumbs is generally used with CMenu
breadcrumbs)):?>
widget('zii.widgets.CBreadcrumbs', array(
'links'=>$this->breadcrumbs,
)); ?>
This example uses Yii’s default CSS, and the result is as follows:
If CSS is not used, the display result is as follows:
It can be seen that you need to use the CMenu component with appropriate CSS to display a beautiful menu.
http://www.bkjia.com/PHPjc/477839.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/477839.htmlTechArticleAfter introducing the Yii database interface, we will introduce Zii components from this article, including list view ListView, table view GridView, It also includes some JQuery-based UI components, such as AutoComplete,...