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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
ba6d887b
Commit
ba6d887b
authored
May 27, 2014
by
Alexander Makarov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #3590: added info about passing parameters to layout
parent
148d19fd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
0 deletions
+24
-0
structure-views.md
docs/guide/structure-views.md
+24
-0
No files found.
docs/guide/structure-views.md
View file @
ba6d887b
...
...
@@ -329,6 +329,30 @@ Several special methods such as [[yii\web\View::beginPage()|beginPage()]]/[[yii\
are triggering page rendering events that are used for registering scripts, links and process page in many other ways.
Always include these in your layout in order for the rendering to work correctly.
By default layout is loaded from `views/layouts/main.php`. You may change it at controller or module level by setting
different value to `layout` propery.
In order to pass data from controller to layout, that you may need for breadcrumbs or similar elements, use view component
data property. In controller it can be set as:
```
php
$this->view->params
[
'breadcrumbs'
][]
= 'Contact';
```
In a view it will be:
```
php
$this->params
[
'breadcrumbs'
][]
= 'Contact';
```
In layout file the value can be used like the following:
```
php
<?= Breadcrumbs::widget(
[
'links' => isset($this->params
[
'breadcrumbs'
]
) ? $this->params
[
'breadcrumbs'
]
:
[
],
]) ?>
```
### Partials
Often you need to reuse some HTML markup in many views and often it's too simple to create a full-featured widget for it.
...
...
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