@@ -27,58 +27,59 @@ or add
27
27
to the require section of your composer.json.
28
28
29
29
30
- Usage
31
- ======================================
32
-
33
- ** 1. Manage comments in admin panel:**
30
+ Configuration
31
+ -----------------------
34
32
35
- 1.1 Add the following code to admin module section in main config
33
+ ** Database Migrations **
36
34
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
+ ```
55
39
56
- ``` 2.1 Add module to config section: ```
40
+ ** Module setup **
57
41
``` php
58
42
'modules' => [
59
43
'comment' => [
60
44
'class' => 'yii2mod\comments\Module'
61
45
]
62
46
]
63
47
```
64
- ``` 2.2 Use in view: ```
65
48
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:**
66
66
``` php
67
67
<?php echo \yii2mod\comments\widgets\Comment::widget([
68
68
'model' => $model,
69
69
'relatedTo' => 'User ' . \Yii::$app->user->identity->username . ' commented on the page ' . \yii\helpers\Url::current() // for example
70
70
]); ?>
71
71
```
72
72
73
- ``` 2.3 You can use your own template for render comments:```
73
+ ** You can use your own template for render comments:**
74
74
75
75
``` php
76
76
<?php echo \yii2mod\comments\widgets\Comment::widget([
77
77
'model' => $model,
78
78
'commentView' => '@app/views/site/comments/index' //path to your template
79
79
]); ?>
80
80
```
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:**
82
83
``` php
83
84
echo \yii2mod\comments\widgets\Comment::widget([
84
85
'model' => $model,
0 commit comments