Skip to content
This repository was archived by the owner on Jan 31, 2020. It is now read-only.

Commit 1139df9

Browse files
committed
Merge branch 'hotfix/177' into develop
Forward port #177
2 parents 60f5dc6 + 492f25b commit 1139df9

File tree

3 files changed

+62
-0
lines changed

3 files changed

+62
-0
lines changed

doc/book/helpers/intro.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ for, and rendering, the various HTML `<head>` tags, such as `HeadTitle`,
7171
- [Identity](identity.md)
7272
- [InlineScript](inline-script.md)
7373
- [JSON](json.md)
74+
- [Layout](layout.md)
7475
- [Partial](partial.md)
7576
- [Placeholder](placeholder.md)
7677
- [Url](url.md)

doc/book/helpers/layout.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Layout
2+
3+
The `Layout` helper is used to get and set the template for the layout or to
4+
retrieving the root view model.
5+
6+
## Basic Usage
7+
8+
### Change the Layout Template
9+
10+
If you're running a zend-mvc application then the layout template is set in the
11+
configuration for the [`ViewManager`](https://docs.zendframework.com/zend-mvc/services/#viewmanager).
12+
13+
To change the layout template within a view script, call:
14+
15+
```php
16+
$this->layout('layout/backend');
17+
```
18+
19+
Or use the `setTemplate` method:
20+
21+
```php
22+
$this->layout()->setTemplate('layout/backend');
23+
```
24+
25+
### Set View Variable on Layout Model
26+
27+
The `Layout` helper can also retrieve the view model for the layout (root):
28+
29+
```php
30+
/** @var \Zend\View\Model\ViewModel $rootViewModel */
31+
$rootViewModel = $this->layout();
32+
```
33+
34+
This offers the possibility to set variables for the layout script.
35+
36+
#### Set a Single Variable
37+
38+
```php
39+
$this->layout()->setVariable('infoText', 'Some text for later');
40+
```
41+
42+
Use in your layout script:
43+
44+
```php
45+
if (isset($infoText)) {
46+
echo $infoText;
47+
}
48+
```
49+
50+
#### Set a Set of Variables
51+
52+
```php
53+
$this->layout()->setVariables([
54+
'headerText' => '…',
55+
'footerText' => '…',
56+
]);
57+
```
58+
59+
More informations related to view models can be found in the
60+
[quick start](https://docs.zendframework.com/zend-view/quick-start/).

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ pages:
2525
- Identity: helpers/identity.md
2626
- InlineScript: helpers/inline-script.md
2727
- Json: helpers/json.md
28+
- Layout: helpers/layout.md
2829
- Partial: helpers/partial.md
2930
- Placeholder: helpers/placeholder.md
3031
- Url: helpers/url.md

0 commit comments

Comments
 (0)