本文实例讲述了Yii实现单用户博客系统文章详情页插入评论表单的方法。分享给大家供大家参考,具体如下:
action部分:
PHP;">
var=10;
}
class one
{
public $var=1;
}
$obj=new one();
echo $obj->var.'
'; test($obj); echo $obj->var; exit;
loadModel($id);
$comment=$this->newComment($post);
$this->render('view',array(
'model'=>$post,'comment'=>$comment,));
}
protected function newComment($post)
{
$comment=new Comment();
if(isset($_POST['Comment']))
{
$comment->attributes=$_POST['Comment'];
if($post->addComment($comment))//==============================
{
if($comment->status==Comment::STATUS_PENDING)
Yii::app()->user->setFlash('commentSubmitted','Thank you...');
$this->refresh();
}
}
return $comment;
}
...
params['commentNeedApproval'])
$comment->status=Comment::STATUS_PENDING;
else
$comment->status=Comment::STATUS_APPROVED;
$comment->post_id=$this->id;
return $comment->save();
}
...
PHP;">
...
Leave a Comment
user->hasFlash('commentSubmitted')): ?>
...
user->getFlash('commentSubmitted'); ?>
renderPartial('/comment/_form',array(
'model'=>$comment,)); ?>
希望本文所述对大家基于Yii框架的PHP程序设计有所帮助。
原文链接:https://www.f2er.com/php/20646.html