Next steps will guide you through the process of installing yii2-vote using composer. Installation is a quick and easy three-step process.
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.
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',
]) ?>
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
Extended information about configuration of this module see in docs/README.md. There you can find:
yii2-vote is released under the BSD 3-Clause License. See the bundled LICENSE.md for details.
See CONTRIBUTING.md for details.
Enjoy and don't hesitate to send issues and pull requests :)