Home  >  Article  >  Backend Development  >  Yii implements the method of displaying static pages, yii implements static_PHP tutorial

Yii implements the method of displaying static pages, yii implements static_PHP tutorial

WBOY
WBOYOriginal
2016-07-12 08:53:22969browse

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

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.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1123836.htmlTechArticleYii realizes the method of displaying static pages, yii realizes static This article describes the method of Yii realizing static pages. Share it with everyone for your reference, the details are as follows: Use Yii’s built-in one...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn