Vote for Yii2 ¶
- Installation
- Documentation
- List of contributors
- Other vote solutions for Yii2
- Articles and tutorials
- Usage examples
- License
- How to contribute
Installation ¶
Next steps will guide you through the process of installing yii2-vote using composer. Installation is a quick and easy three-step process.
Step 1: Install component via composer ¶
Run command
php composer.phar require --prefer-dist chiliec/yii2-vote "^4.2"
or add
"chiliec/yii2-vote": "^4.2"
to the require section of your composer.json
file.
Step 2: Configuring your application ¶
Add following lines to your main configuration file:
'bootstrap' => [
'chiliec\vote\components\VoteBootstrap',
],
'modules' => [
'vote' => [
'class' => 'chiliec\vote\Module',
// show messages in popover
'popOverEnabled' => true,
// global values for all models
// 'allowGuests' => true,
// 'allowChangeVote' => true,
'models' => [
// example declaration of models
// \common\models\Post::className(),
// 'backend\models\Post',
// 2 => 'frontend\models\Story',
// 3 => [
// 'modelName' => \backend\models\Mail::className(),
// you can rewrite global values for specific model
// 'allowGuests' => false,
// 'allowChangeVote' => false,
// ],
],
],
],
And add widget in view:
<?php echo \chiliec\vote\widgets\Vote::widget([
'model' => $model,
// optional fields
// 'showAggregateRating' => true,
]); ?>
Also you can add widget for display top rated models:
<?php echo \chiliec\vote\widgets\TopRated::widget([
'modelName' => \common\models\Post::className(),
'title' => 'Top rated models',
'path' => 'site/view',
'limit' => 10,
'titleField' => 'title',
]) ?>
Step 3: Updating database schema ¶
After you downloaded and configured Yii2-vote, the last thing you need to do is updating your database schema by applying the migrations:
$ php yii migrate/up --migrationPath=@vendor/chiliec/yii2-vote/migrations
Documentation ¶
Extended information about configuration of this module see in docs/README.md. There you can find:
- Migration from 2.* to 3.0
- Manually add behavior in models
- Sorting by rating in data provider
- Overriding views
- Customizing JS-events
- Rich snippet in search engines
List of contributors ¶
- chiliec - Maintainer
- loveorigami - Ideological inspirer
- fourclub - PK name fix in behavior
- yurkinx - Duplication js render fix
- n1k88 - German translation
- teranchristian - Add popover to display messages
- Skatox - Add support for PostgreSQL
Other vote solutions for Yii2 ¶
- yii2-vote by hauntd - it allows you to attach vote widgets, like and favorite buttons to your models
- yii2-vote by bigdropinc - another solution with same name
Articles and tutorials ¶
Usage examples ¶
- Your site could be the first in this list
License ¶
yii2-vote is released under the BSD 3-Clause License. See the bundled LICENSE.md for details.
How to contribute ¶
See CONTRIBUTING.md for details.
Enjoy and don't hesitate to send issues and pull requests :)
Hello I did try this extention but seems it's not working
I'm getting this error : SyntaxError: expected expression, got ','
@Bynd can you take me some more information about file and line where you get this error?
I do the right configuration, create the migrations and when voting, the message "not found" appears and the console shows an error/vote/default/vote 404 not found, the error says something about jquery. Would you help me?
@luismanoel12 this error means that controller/action not accessible via default path. Check configuration, try manually add controller or create issue in github repository with more information about php, yii version etc. And add link to your repo if your app is open source. Thanks for trying to use my extension :)
Hey @Chiliec, I created this topic here on the forum trying to explain a little more, if you can please take a look.
https://forum.yiiframework.com/t/help-with-chiliec-yii2-vote/130734
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.