netcommons/content-comments
最新稳定版本:3.3.7.0
Composer 安装命令:
composer require netcommons/content-comments
包简介
ContentComments for NetCommons Plugin
README 文档
README
phpdoc
概要
コンテンツの一覧にコメント数を表示する機能と、コンテンツの詳細でコメントを投稿する機能を提供します。
利用するプラグインはコメントの使用有無(use_comment)、コメントの承認有無(use_comment_approval)を定義してください。
コンテンツの一覧にコメント数を表示
ContentCommentBehaviorとContentCommentHelperを使用します。
コメントと紐づくモデルにContentCommentBehavior、
コンテンツ一覧のコントローラーにContentCommentHelperを定義してください。
サンプルコード
コントローラー
class VideosController extends VideosAppController { public $uses = array( 'Videos.Video', 'Videos.VideoSetting' ); public $helpers = array( 'ContentComments.ContentComment' => array( 'viewVarsKey' => array( 'contentKey' => 'video.Video.key', 'contentTitleForMail' => 'video.Video.title', 'useComment' => 'videoSetting.use_comment', 'useCommentApproval' => 'videoSetting.use_comment_approval' ) ) ); public function index() { $query = array( 'conditions' => array( 'VideoSetting.block_key' => Current::read('Block.key') ) ); $viewVars['videoSetting'] = $this->VideoSetting->find('first', $query); $viewVars['videos'] = $this->Video->find('all'); $this->set($viewVars); } }
モデル
class Video extends VideoAppModel { public $actsAs = array( 'ContentComments.ContentComment' ); }
ビュー(ctpテンプレート)
<?php foreach ($videos as $video) { echo $video['Video']['title']; echo $this->ContentComment->count($video); } ?>
コンテンツの詳細でコメントを投稿する
ContentCommentsComponentとContentCommentHelperを使用します。
コンテンツ詳細のコントローラーにContentCommentsComponentを定義してください。
サンプルコード
コントローラー
class VideosController extends VideosAppController { public $uses = array( 'Videos.Video', 'Videos.VideoSetting' ); public $components = array( 'ContentComments.ContentComments' => array( 'viewVarsKey' => array( 'contentKey' => 'video.Video.key', 'contentTitleForMail' => 'video.Video.title', 'useComment' => 'videoSetting.use_comment' 'useCommentApproval' => 'videoSetting.use_comment_approval' ), 'allow' => array('view') ) ) public function view($videoKey) { $query = array( 'conditions' => array( 'VideoSetting.block_key' => Current::read('Block.key') ) ); $viewVars['videoSetting'] = $this->VideoSetting->find('first', $query); $query = array( 'conditions' => array( 'Video.key' => $videoKey, 'Video.language_id' => Current::read('Language.id') ) ); $viewVars['video'] = $this->Video->find('first', $query); $this->set($viewVars); } }
ビュー(ctpテンプレート)
<?php
echo $video['title'];
echo $this->ContentComment->index($video);
?>
统计信息
- 总下载量: 25.73k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 5
- 推荐数: 0
其他信息
- 授权协议: LicenseRef-NetCommons
- 更新时间: 2015-04-24