open20/amos-comments

此包的最新版本(1.11.1)没有可用的许可信息。

内容评论 - 插件

1.11.1 2023-10-26 20:11 UTC

README

用于评论新闻、事件等内容...

安装

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

运行以下命令

composer require open20/amos-comments

或将此行

"open20/amos-comments": "dev-master"

添加到您的 composer.json 文件的 require 部分。

2 在后端主配置中添加模块

<?php
'modules' => [
    'comments' => [
        'class' => 'open20\amos\comments\AmosComments',
        'modelsEnabled' => [
            /**
             * Add here the classnames of the models where you want the comments
             * (i.e. 'open20\amos\events\models\Event')
             */
        ],
        // the following are mandatory fields
        'displayNotifyCheckbox' => true, // if the notify checkbox in the accordion must be shown (if hidden, the notify checkbox is selected)
        'accordionOpenedByDefault' => false, // if the accordion must be opened by default
    ],
],

同时,将这些行添加到您的 bootstrap

<?php
'bootstrap' => [
    'comments',
],

3 在 common 中将视图组件添加到主配置

<?php
'components' => [
    'view' => [
        'class' => 'open20\amos\core\components\AmosView',
    ],
],

4 应用迁移

php yii migrate/up --migrationPath=@vendor/open20/amos-comments/src/migrations

或在控制台中添加此行到迁移配置

<?php
return [
    '@vendor/open20/amos-comments/src/migrations',
];

5 在您的模型中实现 CommentInterface

<?php
use open20\amos\comments\models\CommentInterface;

/**
 * Implement the CommentInterface
 */
class MyClass implements CommentInterface

/**
 * Add the required method that must return boolean
 */
public function isCommentable()
{
    return true;
}

6 在后端/config/main.php 的模块配置中添加您的模型到 modulesEnables

<?php
'modules' => [
    'comments' => [
        'class' => 'open20\amos\comments\AmosComments',
        'modelsEnabled' => [
            'class_namespace\MyClass'
        ]
    ],
],

7 禁用邮件通知

<?php
'modules' => [
    'comments' => [
        'class' => 'open20\amos\comments\AmosComments',
        'enableMailsNotification' => false,
        'modelsEnabled' => [
            'class_namespace\MyClass'
        ]
    ],
],

*htmlMailContent - 字符串/数组
在插入评论时更改通知邮件的内容,您可以插入一个数组

  'comments' => [
       'htmlMailContent' => [
            'open20\amos\news\models\News' => '@backend/mail/comment/content_news',
            'open20\amos\discussioni\models\DiscussioniTopic' => '@backend/mail/comment/content_discussioni',
            'open20\amos\documenti\models\Documenti' => '@backend/mail/comment/content_documenti'
        ],

或一个字符串,如果内容对所有内容(新闻/讨论/文档等)有效

  'comments' => [
    'htmlMailContent' => '@backend/mail/comment/content_news'
    ]

仅启用具有范围的评论 *enableCommentOnlyWithScope - 布尔值 默认 false
如果为 true,则仅启用具有范围的评论(在社区中)

  'comments' => [
       'enableCommentOnlyWithScope' => true,
  ]