sadovojav / yii2-inline-widgets-behavior
Add widget into content
Installs: 799
Dependents: 1
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 2
Open Issues: 0
Type:yii2-extension
Requires
- php: >=5.4.0
- yiisoft/yii2: *
This package is auto-updated.
Last update: 2024-11-29 04:14:28 UTC
README
This is a fork howardEagle/yii2-inline-widgets-behavior
Installation
Composer
The preferred way to install this extension is through Composer.
Either run php composer.phar require sadovojav/yii2-inline-widgets-behavior ""dev-master"
or add "sadovojav/yii2-inline-widgets-behavior": ""dev-master"
to the require section of your composer.json
Config
- Add the runtime widgets in your config file:
'params' => [ // ... 'runtimeWidgets' => [ 'sadovojav\gallery\widgets\Gallery' ] ]
- runtimeWidgets must contain list of widgets
- Add behavior in your controller:
public function behaviors() { return [ 'InlineWidgetsBehavior' => [ 'class' => sadovojav\iwb\InlineWidgetsBehavior::className(), 'widgets' => Yii::$app->params['runtimeWidgets'], ] ]; }
- string
namespace
= `` - Default namespace - string
startBlock
=[*
- Start inline widget block - string
endBlock
=*]
- End inline widget block - string
classSuffix
= `` - Default widget Class suffix - string
cacheDuration
=0
- Default cache duration
- Add decodeWidget in view:
<?= $this->context->decodeWidgets($model->text); ?>
Using
Add decodeWidget in view:
<?= $this->context->decodeWidgets($model->text); ?>
For insert widgets in content you can use string of this format in your text:
<startBlock><WidgetName>[|<attribute>=<value>[;<attribute>=<value>]]<endBlock>
For example:
<h2>Lorem ipsum</h2> <h2>Gallery 1</h2> <p>[*Gallery*]</p> <h2>Gallery (with attr)</h2> <p>[*Gallery|template=tpl-1*]</p> <h2>Gallery (with inner caching)</h2> <p>[*Gallery|template=tpl-1;cache=300*]</p>