定制 sadovojav/yii2-inline-widgets-behavior 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

sadovojav/yii2-inline-widgets-behavior

Composer 安装命令:

composer require sadovojav/yii2-inline-widgets-behavior

包简介

Add widget into content

README 文档

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

  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:

<?= $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>

统计信息

  • 总下载量: 799
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2015-09-26