salehasadi / yii2-rating
完整的评分管理系统
dev-master
2016-08-10 11:51 UTC
Requires
- php: >=5.3.2
- kartik-v/yii2-widget-rating: *
- yiidoc/yii2-redactor: *
- yiisoft/yii2: *
- yiisoft/yii2-imagine: ~2.0.0
This package is not auto-updated.
Last update: 2024-09-15 01:40:31 UTC
README
yii2-widget-rating
安装
安装此扩展的首选方式是通过composer。
1- 在您的项目composer中运行以下命令进行安装
$ php composer.phar require salehasadi/yii2-rating
2- 在项目视图中的用户评分展示部分放置以下代码
<?php echo kartik\rating\StarRating::widget(['name' => 'rating_35','value' => 3,'pluginOptions' => ['displayOnly' => true]]);?>
3- 在网站视图中的评分模块(通常位于模态中)放置以下代码
<span id="start" class="target"><!-- Hidden anchor to close all modals --></span> <span id="about_<?= $models->id ?>" class="target"><!-- Hidden anchor to open adjesting modal container--></span> <div class="modal"> <div class="content vertical-align-middle"> <?php $module = Yii::$app->getModule('rating'); ?> <?php echo salehasadi\rating\components\StarRating::widget(['service_id' => $module->services['car'], 'item_id' => $models->id]); ?> <p>Please rate this app</p> <a href="" class="rate" id="">ثبت نظر</a> <a class="close-btn" href="#start">X</a> </div> </div> <div class="page-container"> <?php if (Yii::$app->user->isGuest) { echo '<p><a href="https:///kmsdev-carwar/user/login">ثبت نظر</a></p>'; } else { ?> <p><a href="#about_<?= $models->id ?>">نظر خود را ثبت کنید</a></p> <?php } ?> </div>
4- 您需要数据库表来存储调查结果
$ php yii migrate/up --migrationPath=@vendor/salehasadi/yii2-rating/migrations
5- 您需要在项目配置中定义此模块
'rating'=>[ 'class' => 'salehasadi\rating\Module', 'services'=>[ 'car' => 1, 'news' => 2, ], ]
6- 在视图上应用样式
use salehasadi\rating\assets\RatingAsset; RatingAsset::register($this);