1. Go to this page and download the library: Download dgoriaev/yii2-comments library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
public function getAvatar()
{
// your custom code
}
public function getUsername()
{
// your custom code
}
// the model to which are added comments, for example:
$model = Post::find()->where(['title' => 'some post title'])->one();
echo \yii2mod\comments\widgets\Comment::widget([
'model' => $model,
]);
echo \yii2mod\comments\widgets\Comment::widget([
'model' => $model,
'commentView' => '@app/views/site/comments/index' // path to your template
]);