/** * 评论管理 * */ public function actionComment() { parent::_acl(); $model = new PostComment(); $criteria = new CDbCriteria(); $condition = '1'; $postTitle = $this->_gets->getParam('postTitle'); $content = $this->_gets->getParam('content'); $postTitle && ($condition .= ' AND post.title LIKE \'%' . $postTitle . '%\''); $content && ($condition .= ' AND t.content LIKE \'%' . $content . '%\''); $criteria->condition = $condition; $criteria->order = 't.id DESC'; $criteria->with = array('post'); $count = $model->count($criteria); $pages = new CPagination($count); $pages->pageSize = 13; $pageParams = XUtils::buildCondition($_GET, array('postTitle', 'content')); $pages->params = is_array($pageParams) ? $pageParams : array(); $criteria->limit = $pages->pageSize; $criteria->offset = $pages->currentPage * $pages->pageSize; $result = $model->findAll($criteria); $this->render('post_comment', array('datalist' => $result, 'pagebar' => $pages)); }
<?php $bagecmsCommentModel = new PostComment(); $bagecmsCommentCriteria = new CDbCriteria(); $bagecmsCommentCriteria->condition = 'post_id=' . $bagecmsShow['id']; $bagecmsCommentCriteria->order = 't.id DESC'; $bagecmsCommentCount = $bagecmsCommentModel->count($bagecmsCommentCriteria); $bagecmsCommentPages = new CPagination($bagecmsCommentCount); $bagecmsCommentPages->pageSize = 15; $bagecmsCommentPageParams = XUtils::buildCondition($_GET, array('id')); $bagecmsCommentPageParams['#'] = 'commentList'; $bagecmsCommentPages->params = is_array($bagecmsCommentPageParams) ? $bagecmsCommentPageParams : array(); $bagecmsCommentCriteria->limit = $bagecmsCommentPages->pageSize; $bagecmsCommentCriteria->offset = $bagecmsCommentPages->currentPage * $bagecmsCommentPages->pageSize; $bagecmsCommentList = $bagecmsCommentModel->findAll($bagecmsCommentCriteria); ?> <div id="comment"> <div class="boxTit "> <h3>最新评论</h3> </div> <div class="bmc"> <?php foreach ($bagecmsCommentList as $key => $row) { ?> <dl class="item clear"> <dt class="user"> <a class="title" ><?php echo CHtml::encode($row->nickname); ?> </a> <span class=" xw0"><?php echo date('Y-m-d H:i:s', $row['create_time']); ?>