Yii implements the method of displaying static pages, and yii implements static

Source: Internet
Author: User

Yii implements the method of displaying static pages, and yii implements static

This article describes how to display static pages in Yii. We will share this with you for your reference. The details are as follows:

Use a CViewAction built in Yii to serve all these pages.

First, set up a controller class such as DocController to overwrite 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, a file named about. php is stored in this directory with the content "about this site". These pages use the default layout file of the application. Therefore, this file only describes the content on this page.

Http://www.yourhost.com/index.php? R = doc/page & view = about

If there are many static pages, you can put them in the 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, you can also customize the CViewAction behavior. For more information about CViewAction, see the API documentation.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.