您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

Yii实现单用户博客系统文章详情页插入评论表单的方法

2024/6/26 4:59:42发布16次查看
本文实例讲述了yii实现单用户博客系统文章详情页插入评论表单的方法。分享给大家供大家参考,具体如下:
action部分:
var=10;}class one{ public $var=1;}$obj=new one();echo $obj->var.'';test($obj);echo $obj->var;exit;

postcontroller.php页面:
.../*** displays a particular model.* @param integer $id the id of the model to be displayed*/public function actionview($id){ $post=$this->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;}...
models/post.php页面:
...public function addcomment($comment){ if(yii::app()->params['commentneedapproval']) $comment->status=comment::status_pending; else $comment->status=comment::status_approved; $comment->post_id=$this->id; return $comment->save();}...
post/view.php页面:
...leave a commentuser->hasflash('commentsubmitted')): ?> user->getflash('commentsubmitted'); ?>
renderpartial('/comment/_form',array( 'model'=>$comment, )); ?>
...
希望本文所述对大家基于yii框架的php程序设计有所帮助。
以上就介绍了yii实现单用户博客系统文章详情页插入评论表单的方法,包括了方面的内容,希望对php教程有兴趣的朋友有所帮助。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product