定制 yeesoft/yii2-comments 二次开发

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

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

yeesoft/yii2-comments

最新稳定版本:0.1.1

Composer 安装命令:

composer require yeesoft/yii2-comments

包简介

Comments Module For Yii2 Framework

README 文档

README

Comments module for Yii 2

This module allows you to easy integrate comments system into your Yii2 application.

Installation

  • Either run
composer require --prefer-dist yeesoft/yii2-comments "~0.1.0"

or add

"yeesoft/yii2-comments": "~0.1.0"

to the require section of your composer.json file.

  • Run migrations
yii migrate --migrationPath=@vendor/yeesoft/yii2-comments/migrations/

Configuration

  • In your config file
'bootstrap' => ['comments'],
'modules'=>[
	'comments' => [
		'class' => 'yeesoft\comments\Comments',
	],
],
  • In you model [optional]
public function behaviors()
{
  return [
    'comments' => [
      'class' => 'yeesoft\comments\behaviors\CommentsBehavior'
    ]
  ];
}
  • How to enable anti-spam protection (using Akismet) [optional]
'modules' => [
	'comments' => [
		...
		 'enableSpamProtection' => true,
		 ...
	],
],
'components' => [
	'akismet' => [
            'class' => 'yeesoft\comments\components\Akismet',
            'apiKey' => '*******', //you can get your apiKey here: https://akismet.com/
	],
],

Usage

  • Widget namespace
use yeesoft\comments\widgets\Comments;
  • Add comment widget in model view using (string) page key :
echo Comments::widget(['model' => $pageKey]); 
  • Or display comments using model name and id:
echo Comments::widget(['model' => 'post', 'model_id' => 1]); 
  • Or display comments using model behavior:
echo Post::findOne(10)->displayComments(); 

Module Options

Use this options to configurate comments module:

  • userModel - User model class name.

  • maxNestedLevel - Maximum allowed nested level for comment's replies.

  • onlyRegistered - Indicates whether not registered users can leave a comment.

  • orderDirection - Comments order direction.

  • nestedOrderDirection - Replies order direction.

  • userAvatar - The field for displaying user avatars.

    Is this field is NULL default avatar image will be displayed. Also it can specify path to image or use callable type.

    If this property is specified as a callback, it should have the following signature: function ($user_id)

    Example of module settings:

      'comments' => [
        'class' => 'yeesoft\comments\Comments',
        'userAvatar' => function($user_id){
          return User::getUserAvatarByID($user_id);
        }
      ]

Screenshots

Flickr - Yii2 Comments Module

统计信息

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

GitHub 信息

  • Stars: 22
  • Watchers: 7
  • Forks: 13
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2015-07-06