- 相对路径 (如 `main`): 在上下文模块的[[yii\base\Module::layoutPath|layout path]]布局路径中查找实际的布局文件,the actual layout file will be looked for under the context module's
The following example shows how you can use blocks to customize specific parts of a layout in a content view.
首先,在内容视图中定一个或多个数据块:
First, in a content view, define one or multiple blocks:
```php
...
...
@@ -488,8 +579,7 @@ First, in a content view, define one or multiple blocks:
<?php$this->endBlock();?>
```
Then, in the layout view, render the blocks if they are available, or display some default content if a block is
not defined.
然后,在布局视图中,数据块可用的话会渲染数据块,如果数据未定义则显示一些默认内容。
```php
...
...
...
@@ -518,12 +608,12 @@ not defined.
```
## 使用视图组件 <a name="using-view-components"></a>
## Using View Components <a name="using-view-components"></a>
[[yii\base\View|View components]] provides many view-related features. While you can get view components
by creating individual instances of [[yii\base\View]] or its child class, in most cases you will mainly use
the `view` application component. You can configure this component in [application configurations](structure-applications.md#application-configurations)