mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-04 22:57:40 +08:00
Update structure-widgets.md
delete repeat content
This commit is contained in:
@ -67,34 +67,20 @@ use yii\helpers\Html;
|
|||||||
注意和调用 [[yii\base\Widget::widget()]] 返回渲染结果不同,
|
注意和调用 [[yii\base\Widget::widget()]] 返回渲染结果不同,
|
||||||
调用 [[yii\base\Widget::begin()]] 方法返回一个可组建小部件内容的小部件实例。
|
调用 [[yii\base\Widget::begin()]] 方法返回一个可组建小部件内容的小部件实例。
|
||||||
|
|
||||||
> Note: Some widgets will use [output buffering](http://php.net/manual/en/book.outcontrol.php) to adjust the enclosed
|
> Note: 当调用 [[yii\base\Widget::end()]] 的时候,一些小部件将使用 [输出缓冲](http://php.net/manual/en/book.outcontrol.php)
|
||||||
> content when [[yii\base\Widget::end()]] is called. For this reason calling [[yii\base\Widget::begin()]] and
|
> 来调整封闭的内容。因此,期望调用 [[yii\base\Widget::begin()]] 和
|
||||||
> [[yii\base\Widget::end()]] is expected to happen in the same view file.
|
> [[yii\base\Widget::end()]] 在同一个视图文件里。
|
||||||
> Not following this rule may result in unexpected output.
|
> 不遵循这个规则可能会导致意外的输出。
|
||||||
|
|
||||||
|
### 配置全局默认值
|
||||||
|
|
||||||
### Configuring global defaults
|
小部件的全局默认值可以通过 DI 容器配置:
|
||||||
|
|
||||||
Global defaults for a widget type could be configured via DI container:
|
|
||||||
|
|
||||||
```php
|
```php
|
||||||
\Yii::$container->set('yii\widgets\LinkPager', ['maxButtonCount' => 5]);
|
\Yii::$container->set('yii\widgets\LinkPager', ['maxButtonCount' => 5]);
|
||||||
```
|
```
|
||||||
|
|
||||||
See ["Practical Usage" section in Dependency Injection Container guide](concept-di-container.md#practical-usage) for
|
详见 [依赖注入容器 "实践中的应用" 一节](concept-di-container.md#practical-usage) 。
|
||||||
details.
|
|
||||||
|
|
||||||
|
|
||||||
### Configuring global defaults
|
|
||||||
|
|
||||||
Global defaults for a widget type could be configured via DI container:
|
|
||||||
|
|
||||||
```php
|
|
||||||
\Yii::$container->set('yii\widgets\LinkPager', ['maxButtonCount' => 5]);
|
|
||||||
```
|
|
||||||
|
|
||||||
See ["Practical Usage" section in Dependency Injection Container guide](concept-di-container.md#practical-usage) for
|
|
||||||
details.
|
|
||||||
|
|
||||||
|
|
||||||
## 创建小部件 <span id="creating-widgets"></span>
|
## 创建小部件 <span id="creating-widgets"></span>
|
||||||
|
|||||||
Reference in New Issue
Block a user