定制 elephantsgroup/yii2-like 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

elephantsgroup/yii2-like

Composer 安装命令:

composer require elephantsgroup/yii2-like

包简介

Yii 2 like module

README 文档

README

To use Elephants Group like module first you must install module, then you can use like widget anywhere in your website.

Installation Steps:

1) run

php composer.phar require elephantsgroup/yii2-like "*"

or add "elephantsgroup/yii2-like": "*" to the require section of your composer.json file.

2) migrate database

yii migrate --migrationPath=vendor/elephantsgroup/yii2-like/migrations

3) add like module to common configuration (common/config.php file)

    ...
    'like' => [
        'class' => 'elephantsGroup\like\Module',
    ],
    ...

4) open access to module in common configuration

    'class' => 'mdm\admin\components\AccessControl',
    'allowActions' => [
        ...
        'like/ajax/*',
        ...
    ]

5) filter admin controller in frontend configuration (frontend/config.php file)

    ...
    'like' => [
        'as frontend' => 'elephantsGroup\like\filters\FrontendFilter',
    ],
    ...

5) filter ajax controller in backend configuration (backend/config.php file)

    ...
    'like' => [
        'as backend' => 'elephantsGroup\like\filters\BackendFilter',
    ],
    ...

Using like widget

Anywhere in your code you can use like widget as follows:


You need to use Likes widget header in your page:
```use elephantsGroup\like\components\Likes;```

Like widget parameters
---

- item (integer): to separate likes between different items.
```<?= Likes::widget(['item' => 1]) ?>```
```<?= Likes::widget(['item' => $model->id]) ?>```

default value for item is 0
- service (integer): to separate likes between various item types.
```<?= Likes::widget(['service' => 1, 'item' => $model->id]) ?>```

for example you can use different values for different modules in your app, and then use like widget separately in modules.
default value for service is 0
- color (string): color of unliked icon heart, default 'black'
```<?= Likes::widget(['service' => 1, ''item' => $model->id, 'color' => 'yellow']) ?>```

- view_file (string): the view file path for rendering

```<?= Likes::widget([
    'service' => 1,
    'item' => $model->id,
    'color' => 'yellow',
    'view_file' => Yii::getAlias('@frontend') . '/views/like/widget.php'
]) ?>```

you can use these variables in your customized view:
* service
* item
* color
* is_like

统计信息

  • 总下载量: 27
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-12-11

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固