dev-master
9999999-devAdd widget into content
The Requires
- php >=5.4.0
- yiisoft/yii2 *
inline yii2 widget behaviors
Wallogit.com
2017 © Pedro Peláez
Add widget into content
This is a fork howardEagle/yii2-inline-widgets-behavior, (*1)
The preferred way to install this extension is through Composer., (*2)
Either run php composer.phar require sadovojav/yii2-inline-widgets-behavior ""dev-master", (*3)
or add "sadovojav/yii2-inline-widgets-behavior": ""dev-master" to the require section of your composer.json, (*4)
'params' => [
// ...
'runtimeWidgets' => [
'sadovojav\gallery\widgets\Gallery'
]
]
public function behaviors()
{
return [
'InlineWidgetsBehavior' => [
'class' => sadovojav\iwb\InlineWidgetsBehavior::className(),
'widgets' => Yii::$app->params['runtimeWidgets'],
]
];
}
namespace = `` - Default namespacestartBlock = [* - Start inline widget blockendBlock = *] - End inline widget blockclassSuffix = `` - Default widget Class suffixcacheDuration = 0 - Default cache duration<?= $this->context->decodeWidgets($model->text); ?>
Add decodeWidget in view:, (*5)
<?= $this->context->decodeWidgets($model->text); ?>
For insert widgets in content you can use string of this format in your text:, (*6)
<startBlock><WidgetName>[|<attribute>=<value>[;<attribute>=<value>]]<endBlock>
Lorem ipsum
Gallery 1
[*Gallery*], (*7)
Gallery (with attr)
[*Gallery|template=tpl-1*], (*8)
Gallery (with inner caching)
[*Gallery|template=tpl-1;cache=300*], (*9)
Add widget into content
inline yii2 widget behaviors