The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist spanjeta/yii2-comments "*"
or add
"spanjeta/yii2-comments": "*"
to the require section of your composer.json file. Usage
Once the extension is installed, use mitration to install table
yii migrate/up --migrationPath=@spanjeta/comments/migrations
simply use it in your code by :
<?= \spanjeta\comments\CommentsWidget::widget(['model'=>$model]); ?>
Where to add the last line of code
Hi I am trying to add your extension to my posts. So I have added the last line of your code
<?= \spanjeta\comments\CommentsWidget::widget(['model'=>$model]); ?>
to my view.php of posts. However i get an error saying"Getting unknown property: app\models\Posts::id".
Could you tell me where exactly should I add that last line.
@zubair
Do you have id in your posts model?
It just the parameter 'id' is assumed in your model.
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.