dmstr/yii2-publication-module

出版物模块

1.3.0-beta3 2023-06-13 13:38 UTC

This package is auto-updated.

Last update: 2024-09-14 16:01:04 UTC


README

出版物模块

安装

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

运行以下命令之一

php composer.phar require --prefer-dist dmstr/yii2-publication-module "*"

"dmstr/yii2-publication-module": "*"

将以下内容添加到你的composer.json文件的require部分

{
    "type": "vcs",
    "url": "https://git.hrzg.de/dmstr/yii2-publication-module.git"
}

和repositories部分:

配置

扩展安装后,只需在代码中添加两个模块到配置文件中的module部分即可使用。

'modules' => [
    'publication' => [
        'class' => dmstr\modules\publication\Module::class,
        'previewItemRole' => null // This describes a rbac role which allowed the user which has grants for this privilege to access the default detail action even if the item is not published
    ]
]

@dmstr/modules/publication/migrations运行迁移。

使用方法

为摘要创建widget-templates /widgets/crud/widget-template/index

{
    "title": "News Teaser",
    "type": "object",
    "properties": {
        "teaser": {
            "type": "string",
            "title": "Teaser",
            "default": "subline"
        }
    }
}

并为内容创建。

{
    "title": "News Content",
    "type": "object",
    "properties": {
        "content": {
            "type": "string",
            "title": "Content",
            "default": "Content"
        }
    }
}

创建一个分类,例如新闻,并将模板分配给它。

创建一个条目。

publication/default/index?categoryId=1

在摘要模板中使用内容架构中的变量

{{ content.headline }}
{{ content.image }}