- Yii 1.1 Application Development Cookbook
- Alexander Makarov
- 191字
- 2021-04-02 18:41:02
Displaying static pages with CViewAction
If you have a few static pages and aren't going to change them very frequently, then it's not worth querying database and implementing a page management for them.
Getting ready
Set up a new application using yiic webapp
.
How to do it...
- We just need to connect
CViewAction
to our controller.class SiteController extends CController { function actions() { return array( 'page'=>array( 'class'=>'CViewAction', ), ); } }
- Now, put your pages into
protected/views/site/pages
. Name themabout.php
andcontact.php
. - Now, you can try your pages by typing:
http://example.com/index.php?r=site/page&view=contact
Alternatively, you can type the following:
http://example.com/site/page/view/about
If you have configured clean URLs with path format.
How it works...
We are connecting external action named CViewAction
that simply tries to find a view named the same as the $_GET
parameter supplied. If it is there, it displays it. If not, then it will give you 404 Not found
page.
There's more...
There are some useful CViewAction
parameters we can use. These are listed in the following table:

Further reading
For further information, refer to the following URL: http://www.yiiframework.com/doc/api/CViewAction
See also
- The recipe named Using external actions in this chapter
- Adobe 創意大學動漫設計師Flash CS5 + Photoshop CS5 標準實訓教材
- 3ds max & VRay產品造型設計經典
- Rhino 6.0中文版入門、精通與實戰
- Maya 2019三維動畫基礎案例教程
- 中文版CorelDRAW基礎培訓教程
- SolidWorks 2019快速自學寶典
- WordPress Theme Design
- Joomla! 1.5 Site Blueprints: LITE
- Premiere Pro CC 2018基礎教程(第3版)
- IBM WebSphere eXtreme Scale 6
- Unity 2020游戲開發快速上手
- 3ds Max/VRay印象燈光/材質/渲染技術精粹Ⅲ
- 零基礎攝影后期修圖 Photoshop照片處理輕松入門
- Excel 2010 Financials Cookbook
- 3ds Max 印象 影視粒子特效全解析