A simple yii extension to keep like dislike functionality
Requirements ¶
- Yii 1.1 or above
- yii-user module
- jquery.js
- url without index.php and urlmanager enabled in config/main.php
INSTALLATION
- Unzip
Copy the likedislike folder to protected/modules/
under config/main/
'modules'=>array( 'likedislike', ),
and under import array in the config file, add
'application.modules.likedislike.models.*',
Import protected/modules/data/tbl_likedislike.sql
You are ready to go
Usage ¶
To display like dislike in blog feeds
<?php $this->widget('likedislike.widgets.LikeDislikeButton',array('field_id'=>your filed/blog/post id*)) ?>
*your filed/blog/post id : it should be the id of the item you want to be liked or disliked
foreach($model as $row){
echo $row->title.$row->post;
$this->widget('likedislike.widgets.LikeDislikeButton',array('field_id'=>$row->id));
}
Array to string conversion ?
what is this supposed to mean ?
'modules'=>array( 'likedislike', ),
Are you sure this is what is to be added to main/config ?
Adding this gives me an error 'Array to string conversion '
And i am trying to use this for liking and disliking comments ? Will it work there ?
If i directly import the module, i get a fatal error:
Fatal error: Call to a member function defaultOnload() on a non-object in C:\xampp\htdocs\swd\protected\modules\likedislike\widgets\LikeDislikeButton.php on line 29
Any suggestions would be appreciated !
thanks for replying and for this extension
Update: Well this works great.. within module you just need to add the string 'likedislike' and not the complete thing as array {'likedislike'}
REPLY: Array to string conversion ?
in the config file, under the return array, you might already have a 'modules' array for configuring 'user' module and others. add a new line 'likedislike' to that array. ... works for me.
and under import array in the config file, add
'application.modules.likedislike.models.*',
and yes, it works for comments. simply pass the "comment id" as 'field_id' parameter.
Thanks.
great extension...
yes...it cool extension..it work on postgresql ...thanks Ashok Poudel
The CSRF token verifiecation.
How i can resolve error "The CSRF token could not be verified."?
Tweaked to work with different models
Great extension, straight forward code.Thank you for your extension.
As it is simple to work only to particular model, i tweaked it to work with different models.
I used one more parameter to call widget and same for js code
<?php $this->widget('likedislike.widgets.LikeDislikeButton', array('post_id' => 5, 'post_type' => 'comment')); ?>
Can check modified code on Git
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.