dmstr/yii2-widgets2-module

Yii 2.0 框架 Widget 管理器

安装数: 48,055

依赖项: 2

建议者: 0

安全: 0

星标: 8

关注者: 9

分支: 8

开放问题: 7

类型:yii2-extension

2.7.4 2024-05-13 11:08 UTC

This package is auto-updated.

Last update: 2024-08-25 06:43:03 UTC


README

Latest Stable Version Total Downloads License

使用 twig 模板进行 Widget 管理的扩展

安装

通过 composer 安装此扩展是首选方式。

运行以下命令到你的 composer.json 文件的 require 部分。

composer require dmstr/yii2-widgets2-module

测试

cd tests

docker-compose up -d

docker-compose run phpfpm bash

setup.sh

配置

...
'modules => [
	'widgets' => [
		'class' => '\hrzg\widget\Module',
		'layout' => '@backend/views/layouts/main',
		'playgroundLayout' => '@frontend/views/layouts/main',
		'dateBasedAccessControl' => true,
		'datepickerMinutes' => false,
		'timezone' => 'Europe/Berlin',
		// set ajax option for JsonEditor
		'allowAjaxInSchema' => false,
        // If true, the json content properties will be validated against the json schema from the widget_template.
        // To be BC the default is false, but you should enable it
		'validateContentSchema' => false
	]
]
...

设置

availablePhpClasses availableFrontendPhpClasses - 具有此设置中列出的任意一个类的模板将被输出到可用模板的单元格 Widget 下拉菜单中(默认: hrzg\widget\widgets\TwigTemplate)

用法

安装扩展后,只需在代码中简单使用它即可

布局

yii2-prototype-module 一起的示例

{{ use ('hrzg/widget/widgets') }}
{{ cell_widget({id: 'main'}) }}

Widget

  • 标准 Twig Widget hrzg\widget\widgets\TwigTemplate
  • 字符-排名排序 001105aa1aa1.2b0(非数字)

JSON

设置

部分:widgets

键:availablePhpClasses

类型:JSON

####示例

{"hrzg\\widget\\widgets\\TwigTemplate": "Twig 布局"}

Widget 示例

基本

{
    "title": "Basic",
    "type": "object",
    "properties": {
        "headline": {
            "type": "string",
            "default": "Avo vole tioma profitanto ts,"
        },
        "text_html": {
            "type": "string",
            "format": "html",
            "default": "Ja sub kiam aliu, fo unt fora danke helpverbo, dev bv tele kibi piedpilko.",
            "options": {
                "wysiwyg": true
            }
        }
    }
}
<h2>{{ headline }}</h2>
<p>{{ text_html }}</p>

更多示例,请参阅 文档

升级

从 0.2 升级到 0.3

{{ cell_widget({id: 'header'}) }}

RBAC

可用的权限项目

设置