- 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
- Yii 1.1 Application Development Cookbook
- 視覺封王:Photoshop CC 2019立體化教程(素材+視頻+教案)
- Liferay User Interface Development
- AI繪畫:Stable Diffusion從入門到精通
- UG NX 9.0中文版基礎與實例教程
- Maya 2020基礎教材
- Vue.js快速入門
- OpenCart 1.4 Template Design Cookbook
- Moodle Course Conversion: Beginner's Guide
- 科技繪圖/科研論文圖/論文配圖設計與創作自學手冊:科研動畫篇
- 中文版3ds Max 2014-VRay效果圖制作完全自學教程
- 中文版Photoshop平面設計入門教程
- Photoshop后期強:多重曝光專業技法寶典
- 中文版Illustrator CC完全自學教程
- 跟著視頻學Excel數據處理:函數篇