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 the database and implementing page management for them.
Getting ready
Set up a new application using yiic webapp.
How to do it...
We just need to connect
CViewActionto our controller.class SiteController extends CController { function actions() { return array( 'page'=>array( 'class'=>'CViewAction', ), ); } }Now, put your pages into
protected/views/site/pages, and name themabout.phpandcontact.php.Now, you can try your pages by typing in the URL
http://example.com/index.php?r=site/page&view=contact.Alternatively, you can type in the URL
http://example.com/site/page/view/about, if you have configured clean URLs with a path format.
How it works...
We connect the external action named CViewAction that simply tries to find a view named the same as the $_GET parameter supplied. If it is there...