国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Home php教程 php手冊(cè) Yii Framework 開發(fā)教程Zii組件-Menu 示例

Yii Framework 開發(fā)教程Zii組件-Menu 示例

Jun 13, 2016 am 10:54 AM
framework yii introduce open develop Tutorial database Example components

?介紹完Yii數(shù)據(jù)庫接口外,從本篇開始介紹Zii組件,包括列表視圖ListView,表格視圖GridView,此外還包括一些基于JQuery的UI組件,如AutoComplete,DataPicker, Button, Drag 和 Drop等。

?

本文介紹Menu菜單用法,CMenu使用Html 列表顯示多級(jí)菜單,Menu配置通過其屬性item來配置,每個(gè)菜單項(xiàng)包括三個(gè)主要屬性

?

visible ?是否可見

active 當(dāng)前菜單項(xiàng)是否選中,

items 子菜單項(xiàng)。

此外還包括如下屬性:

?

label: 可選,菜單名稱,支持使用HTML標(biāo)記.

url: 可選,點(diǎn)擊該菜單轉(zhuǎn)的URL鏈接

template: 可選,菜單模板www.2cto.com

linkOptions: array, 可選,額外的HTML鏈接屬性

itemOptions: array, 可選,額外的顯示菜單項(xiàng)的HTML屬性。

submenuOptions: array, 可選,額外顯示子菜單的HTML屬性.

一般可以把Menu定義在Layout布局中,比如本例,修改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),

),

)); ?>

?

本例使用CViewAction來顯示幾個(gè)靜態(tài)頁面,靜態(tài)頁面的缺省目錄為當(dāng)前Controller的View目錄下的pages子目錄,本例在pages目錄下創(chuàng)建了兩個(gè)靜態(tài)頁面about.php, contact.

要使用CViewAction來顯示靜態(tài)頁面,需要修改Controller的actions方法:

?

?

?

public function actions()

{

return array(

'page'=>array(

'class'=>'CViewAction',

)

);

}

?

此外如果要顯示菜單的層次軌跡(breadcrumbs),可以使用Zii組件中的CBreadcrumbs組件,CBreadcrumbs一般配合CMenu使用

?

?

?

breadcrumbs)):?>

widget('zii.widgets.CBreadcrumbs', array(

'links'=>$this->breadcrumbs,

)); ?>

?

?

?

本例使用Yii缺省的CSS,顯示結(jié)果如下:

?

?

如果不使用CSS,顯示結(jié)果如下:

?

?

?

?

由此可見,需要同時(shí)使用CMenu組件配合合適的CSS才能顯示漂亮的菜單。

?

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

PHP Tutorial
1502
276
How to install MySQL 8.0 on Windows/Linux? How to install MySQL 8.0 on Windows/Linux? Jun 11, 2025 pm 03:25 PM

The key to installing MySQL 8.0 is to follow the steps and pay attention to common problems. It is recommended to use the MSI installation package on Windows. The steps include downloading the installation package, running the installer, selecting the installation type, setting the root password, enabling service startup, and paying attention to port conflicts or manually configuring the ZIP version; Linux (such as Ubuntu) is installed through apt, and the steps are to update the source, installing the server, running security scripts, checking service status, and modifying the root authentication method; no matter which platform, you should modify the default password, create ordinary users, set up firewalls, adjust configuration files to optimize character sets and other parameters to ensure security and normal use.

How to view all databases in MongoDB How to view all databases in MongoDB Jun 04, 2025 pm 10:42 PM

The way to view all databases in MongoDB is to enter the command "showdbs". 1. This command only displays non-empty databases. 2. You can switch the database through the "use" command and insert data to make it display. 3. Pay attention to internal databases such as "local" and "config". 4. When using the driver, you need to use the "listDatabases()" method to obtain detailed information. 5. The "db.stats()" command can view detailed database statistics.

How do I create new records in the database using Eloquent? How do I create new records in the database using Eloquent? Jun 14, 2025 am 12:34 AM

To create new records in the database using Eloquent, there are four main methods: 1. Use the create method to quickly create records by passing in the attribute array, such as User::create(['name'=>'JohnDoe','email'=>'john@example.com']); 2. Use the save method to manually instantiate the model and assign values ??to save one by one, which is suitable for scenarios where conditional assignment or extra logic is required; 3. Use firstOrCreate to find or create records based on search conditions to avoid duplicate data; 4. Use updateOrCreate to find records and update, if not, create them, which is suitable for processing imported data, etc., which may be repetitive.

How do I install Yii on my operating system (Windows, macOS, Linux)? How do I install Yii on my operating system (Windows, macOS, Linux)? Jun 17, 2025 am 09:21 AM

To install the Yii framework, you need to configure PHP and Composer according to different operating systems. The specific steps are as follows: 1. You need to manually download PHP and configure environment variables on Windows, then install Composer, use commands to create a project and run a built-in server; 2. It is recommended to use Homebrew to install PHP and Composer, then create a project and start a development server; 3. Linux (such as Ubuntu) install PHP, extensions and Composer through apt, then create a project and deploy a formal environment with Apache or Nginx. The main differences between different systems are in the environment construction stage. Once PHP and Composer are ready, the subsequent processes are consistent. Note

What is the purpose of SELECT ... FOR UPDATE? What is the purpose of SELECT ... FOR UPDATE? Jun 11, 2025 pm 03:37 PM

ThemainpurposeofSELECT...FORUPDATEistolockselectedrowsduringatransactiontopreventothersessionsfrommodifyingthemuntilthetransactioncompleteswhichensuresdataconsistencyinconcurrentenvironmentssuchasbankingandinventorysystems1Itplacesrow-levellocksallow

Redis vs databases: what are the limits? Redis vs databases: what are the limits? Jul 02, 2025 am 12:03 AM

Redisislimitedbymemoryconstraintsanddatapersistence,whiletraditionaldatabasesstrugglewithperformanceinreal-timescenarios.1)Redisexcelsinreal-timedataprocessingandcachingbutmayrequirecomplexshardingforlargedatasets.2)TraditionaldatabaseslikeMySQLorPos

Yii vs. Laravel: Choosing the Right PHP Framework for Your Project Yii vs. Laravel: Choosing the Right PHP Framework for Your Project Jul 02, 2025 am 12:26 AM

The choice of Yii or Laravel depends on project requirements and team expertise. 1) Yii is suitable for high performance needs and has a lightweight structure. 2) Laravel provides rich functions, is developer-friendly and suitable for complex applications. Both are scalable, but Yii is easier to modular, while Laravel community is more resourceful.

What is the leftmost prefix rule for composite indexes? What is the leftmost prefix rule for composite indexes? Jun 12, 2025 am 10:36 AM

Theleftmostprefixruleincompositeindexesmeansqueriesmustreferencetheleftmostcolumnstousetheindexeffectively.Forexample,anindexon(last_name,first_name,email)helpsqueriesfilteringonlast_name,last_nameandfirst_name,orallthreecolumns.However,queriesfilter

See all articles