Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Rotua Panjaitan
yii2
Commits
e842dec5
Commit
e842dec5
authored
Apr 17, 2014
by
Alexander Makarov
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3141 from githubjeka/patch-3
Add static page
parents
a3632dbb
2edc8953
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
0 deletions
+46
-0
view.md
docs/guide/view.md
+46
-0
No files found.
docs/guide/view.md
View file @
e842dec5
...
@@ -396,6 +396,52 @@ view rendered by controller we can use the following:
...
@@ -396,6 +396,52 @@ view rendered by controller we can use the following:
echo $this->context->getRoute();
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.
*How use:*
**create action in controller**
```
php
class SiteController extends Controller
{
public function actions()
{
return
[
'static' =>
[
'class' => '
\y
ii
\w
eb
\V
iewAction',
],
];
}
//...
}
```
**create `index.php` in `@app/views/site/pages/`**
```
php
//index.php
<h1>
View static page
</h1>
```
**open url `/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`
By default:
* GET parameter = `view`
* view file = `index.php`
* folder(viewPrefix) = `pages`
* layout for static page use as that in the current controller.
These parameters can be changed.
For more information see [[yii\web\ViewAction]]
### Caching blocks
### Caching blocks
To learn about caching of view fragments please refer to [caching](caching.md) section of the guide.
To learn about caching of view fragments please refer to [caching](caching.md) section of the guide.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment