2017 © Pedro Peláez
 

yii2-extension yii2-inline-widgets-behavior

Add widget into content

image

sadovojav/yii2-inline-widgets-behavior

Add widget into content

  • Saturday, September 26, 2015
  • by sadovojav
  • Repository
  • 1 Watchers
  • 1 Stars
  • 598 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 1 Versions
  • 3 % Grown

The README.md

Yii2 inline widget

This is a fork howardEagle/yii2-inline-widgets-behavior, (*1)

Installation

Composer

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)

Config

  1. Add the runtime widgets in your config file:
'params' => [
     // ...
    'runtimeWidgets' => [
        'sadovojav\gallery\widgets\Gallery'
    ]
]
  • runtimeWidgets must contain list of widgets
  1. 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
  1. Add decodeWidget in view:
<?= $this->context->decodeWidgets($model->text); ?>

Using

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>
For example:


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)

The Versions

26/09 2015

dev-master

9999999-dev

Add widget into content

  Sources   Download

The Requires

 

inline yii2 widget behaviors