Skip to content

Commit 1186b08

Browse files
author
Igor Chepurnoy
authored
Update README.md
1 parent 51e165b commit 1186b08

File tree

1 file changed

+28
-27
lines changed

1 file changed

+28
-27
lines changed

README.md

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -27,58 +27,59 @@ or add
2727
to the require section of your composer.json.
2828

2929

30-
Usage
31-
======================================
32-
33-
**1. Manage comments in admin panel:**
30+
Configuration
31+
-----------------------
3432

35-
1.1 Add the following code to admin module section in main config
33+
**Database Migrations**
3634

37-
```php
38-
'controllerMap' => [
39-
'comments' => 'yii2mod\comments\controllers\ManageController'
40-
]
41-
```
42-
1.2 Run migrations:
43-
44-
```php
45-
php yii migrate --migrationPath=@vendor/yii2mod/yii2-comments/migrations
46-
```
47-
48-
**You can then access to management section through the following URL:**
49-
```
50-
http://localhost/path/to/index.php?r=admin/comments/index
51-
```
52-
53-
54-
**2. Usage comment widget in view:**
35+
Before using Comments Widget, we'll also need to prepare the database.
36+
```php
37+
php yii migrate --migrationPath=@vendor/yii2mod/yii2-comments/migrations
38+
```
5539

56-
```2.1 Add module to config section:```
40+
**Module setup**
5741
```php
5842
'modules' => [
5943
'comment' => [
6044
'class' => 'yii2mod\comments\Module'
6145
]
6246
]
6347
```
64-
```2.2 Use in view:```
6548

49+
**Comments management section setup**
50+
```php
51+
'controllerMap' => [
52+
'comments' => 'yii2mod\comments\controllers\ManageController'
53+
]
54+
```
55+
> Basically the above code must be placed in the `admin` module
56+
57+
You can then access to management section through the following URL:
58+
http://localhost/path/to/index.php?r=comments/index
59+
60+
> If you have added this controller in the module admin, the URL will look like the following
61+
> http://localhost/path/to/index.php?r=admin/comments/index
62+
63+
Usage
64+
-------------------
65+
**Basic example:**
6666
```php
6767
<?php echo \yii2mod\comments\widgets\Comment::widget([
6868
'model' => $model,
6969
'relatedTo' => 'User ' . \Yii::$app->user->identity->username . ' commented on the page ' . \yii\helpers\Url::current() // for example
7070
]); ?>
7171
```
7272

73-
```2.3 You can use your own template for render comments:```
73+
**You can use your own template for render comments:**
7474

7575
```php
7676
<?php echo \yii2mod\comments\widgets\Comment::widget([
7777
'model' => $model,
7878
'commentView' => '@app/views/site/comments/index' //path to your template
7979
]); ?>
8080
```
81-
```2.4 Use the following code for multiple widgets on the same page:```
81+
82+
**Use the following code for multiple widgets on the same page:**
8283
```php
8384
echo \yii2mod\comments\widgets\Comment::widget([
8485
'model' => $model,

0 commit comments

Comments
 (0)