Skip to content

yii2song/yii2-comments

 
 

Repository files navigation

Comments module for Yii2

This module provide a comments managing system for Yii2 application.

Installation

The preferred way to install this extension is through composer.

Either run

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

or add

"yii2mod/yii2-comments": "*"

to the require section of your composer.json.

Usage

1. Manage comments in admin panel:

1.1 Add the following code to admin module section in main config
'controllerMap' => [
      'comments' => 'yii2mod\comments\controllers\ManageController'
]  
1.2 Run migrations:
    php yii migrate --migrationPath=@vendor/yii2mod/yii2-comments/migrations

You can then access to management section through the following URL:

  http://localhost/path/to/index.php?r=admin/comments/index

2. Usage comment widget in view:

2.1 Add module to config section:

'modules' => [
    'comment' => [
        'class' => 'yii2mod\comments\Module'
    ]
]

2.2 Use in view:

<?php echo \yii2mod\comments\widgets\Comment::widget([
    'model' => $model
]); ?>

2.3 Also you can use own template for render comments.

<?php echo \yii2mod\comments\widgets\Comment::widget([
  'model' => $model,
  'commentView' => '@app/views/site/comments/index' //path to your template
]); ?>

Example comments


Alt text

Packages

No packages published

Languages

  • PHP 76.1%
  • JavaScript 13.8%
  • CSS 10.1%