The example in this article describes the method of Yii implementing static pages. Share it with everyone for your reference, the details are as follows:
Use Yii’s built-in CViewAction to serve all these pages.
First, create a controller class such as DocController and override the actions method
public function actions() { return array( 'page'=>array( 'class'=>'CViewAction', ), ); }
According to the official guide, the above code declares an external action class CViewAction.
Then, generate the directory protected/views/doc/pages.
Finally, store a file called about.php in this directory with the content: "about this site". At this time, these pages will use the application's default layout file. Therefore this file only describes the content relevant to this page.
http://www.yourhost.com/index.php?r=doc/page&view=about
If there are many static pages, you can place them in a subdirectory. Suppose there is a static page in protected/views/doc/pages/help/contact.php:
http://www.yourhost.com/index.php?r=doc/page&view=help.contact
Of course, we can also customize the behavior of CViewAction. Check the API documentation to learn more about CViewAction
Readers who are interested in more Yii-related content can check out the special topics on this site: "Introduction to Yii Framework and Summary of Common Techniques", "Summary of Excellent PHP Development Framework", "Basic Tutorial for Getting Started with Smarty Templates", "php Date and Time" Usage Summary", "php object-oriented programming introductory tutorial", "php string (string) usage summary", "php mysql database operation introductory tutorial" and "php common database operation skills summary"
I hope this article will be helpful to everyone’s PHP program design based on the Yii framework.