Commit 0842c4a7 by Alexander Makarov

Adjusted statc pages docs

parent e842dec5
......@@ -398,12 +398,10 @@ echo $this->context->getRoute();
### Static Pages
For render static pages, you can use class `ViewAction`.
ViewAction represents an action that displays a view according to a user-specified parameter.
If you need to render static pages you can use class `ViewAction`. It represents an action that displays a view according
to a user-specified parameter.
*How use:*
**create action in controller**
Usage of the class is simple. In your controller use the class via `actions` method:
```php
class SiteController extends Controller
......@@ -421,26 +419,26 @@ class SiteController extends Controller
}
```
**create `index.php` in `@app/views/site/pages/`**
Then create `index.php` in `@app/views/site/pages/`:
```php
//index.php
<h1>View static page</h1>
<h1>Hello, I am a static page!</h1>
```
**open url `/index.php?r=site/static`**
That's it. Now you can try it using `/index.php?r=site/static`.
By default, the view being displayed is specified via the `view` GET parameter.
If you open url `/index.php?r=site/static?&view=about` then will be opened view of file `@app/views/site/pages/about.php`
If you open `/index.php?r=site/static?&view=about` then `@app/views/site/pages/about.php` view file will be used.
By default:
* GET parameter = `view`
* view file = `index.php`
* folder(viewPrefix) = `pages`
* layout for static page use as that in the current controller.
If not changed or specified via GET defaults are the following:
These parameters can be changed.
- GET parameter name: `view`.
- View file used if parameter is missing: `index.php`.
- Directory where views are stored (`viewPrefix`): `pages`.
- Layout for the page rendered matches the one used in controller.
For more information see [[yii\web\ViewAction]]
For more information see [[yii\web\ViewAction]].
### Caching blocks
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment