我使用的是cakephp2.0,我想集成评论插件,但我没有得到任何东西,.I使用的是commentDc插件,但它不是我的requirements.Because,我正在将我的用户登录系统与xenforo和commentDc插件集成在一起,使用Auth组件,所以它不能正常工作。
请告诉我是否有任何简单的评论插件,我可以集成和修改作为我的需要。
谢谢,
发布于 2012-05-25 02:40:38
下面是我如何设置评论:
注释表字段:
的parent
在您想要评论的任何模型中,在此您的关联:
public $hasMany = array(
'Comment' => array(
'className' => 'Comment',
'foreignKey' => 'parent_id',
'conditions' => array('Comment.parent_type' => 'question')
)
);这是一个视图元素:
<?php
/*
set variables:
$data : data of the parent
$type : the type of the parent
*/
if(!isset($name)) {
$name = 0;
}
foreach($data['Comment'] as $comment){
echo '<div class="comment">'.$comment['content'].
' - '.$this->Html->link($comment['User']['username'],array('controller'=>'users','action'=>'view',$comment['User']['id']))
.'</div>';
}
echo $this->Form->create(null, array('url' => '/comments/add','id'=>'qCommentForm'));
echo $this->Form->input('Comment.parent_id', array('type'=>'hidden','value'=>$data[$type]['id']));
echo $this->Form->input('Comment.parent_type', array('type'=>'hidden','value'=>$type));
echo $this->Form->textarea('Comment.content',array('div'=>'false','class'=>'small','label'=>false));
echo $this->Form->submit(__('Leave comment'),array('div'=>'false','class'=>'small'));
echo $this->Form->end();
?>然后,在模型的视图视图中添加以下内容(假设您将元素命名为comment.ctp):
<?php echo $this->element('comment',array('data'=>$modelData,'type'=>'MyModel')) ?> https://stackoverflow.com/questions/10732948
复制相似问题