私は Cakephp2.0 を使用していて、コメント プラグインを統合したいのですが、何も得られませんでした。ちゃんと。
必要に応じて統合および変更できる簡単なコメント プラグインがあれば教えてください。
ありがとう、
私は Cakephp2.0 を使用していて、コメント プラグインを統合したいのですが、何も得られませんでした。ちゃんと。
必要に応じて統合および変更できる簡単なコメント プラグインがあれば教えてください。
ありがとう、
コメントの設定方法は次のとおりです。
コメント テーブルのフィールド:
コメント可能にしたいモデルでは、これであなたの関連付け:
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();
?>
次に、モデルのビュー view で、これを追加します (要素に comment.ctp という名前を付けたと仮定します:
<?php echo $this->element('comment',array('data'=>$modelData,'type'=>'MyModel')) ?>