stepancher/yii2-comments-module

The comments module for Yii2 application.

Installs: 478

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 4

Forks: 12

Type:yii2-extension

0.1.3 2015-03-01 13:32 UTC

This package is not auto-updated.

Last update: 2020-11-23 08:27:16 UTC


README

This module provide a comments managing system for Yii2-Start application.

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist stepancher/yii2-comments-module "*"

or add

"stepancher/yii2-comments-module": "*"

to the require section of your composer.json file.

Configuration

  • Add module to config section:
'modules' => [
    'comments' => [
        'class' => 'stepancher\comments\Module'
    ]
]
  • Run migrations:
php yii migrate --migrationPath=@stepancher/comments/migrations
  • Run RBAC command:
php yii comments/rbac/add

Usage:

  • Add a new comment-on-able model namespace in yii2-start.domain/backend/comments/models/index/
  • Add Comments widget in your view file:
echo \stepancher\comments\widgets\Comments::widget(
    [  
        'model' => $model,  
        'jsOptions' => [  
            'listSelector' => '[data-comment="list"]', // Comment list selector 
            'parentSelector' => '[data-comment="parent"]', // Comment parent selector
            'appendSelector' => '[data-comment="append"]', // Container selector where "reply" and "edit" form will be appended by jQuery
            'formSelector' => '[data-comment="form"]', // Comment form selector
            'contentSelector' => '[data-comment="content"]', // Comment content selector
            'toolsSelector' => '[data-comment="tools"]', // Comment tools selector
            'formGroupSelector' => '[data-comment="form-group"]', // Comment form group selector
            'errorSummarySelector' => '[data-comment="form-summary"]', // Comment form summary error selector
            'errorSummaryToggleClass' => 'hidden', // Comment summary error class that will be add/remove by jQuery on error reporting
            'errorClass' => 'has-error', // Comment form group error class
            'offset' => 0 // Top offset for scrollTo function. Use it if you have fixed top menu for correct scrolling to comment's parent. In case with fixed menu, "offset" value must be equal with menu block height.
        ]  
    ]  
);
  • Profit!