/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Articlecomment::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'articleId' => $this->articleId, 'userId' => $this->userId, 'createTime' => $this->createTime, 'parentId' => $this->parentId]); $query->andFilterWhere(['like', 'content', $this->content]); return $dataProvider; }
/** * Finds the Articlecomment model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Articlecomment the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Articlecomment::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
<?php use yii\helpers\Html; use app\models\Answer; use app\models\Articlecomment; if ('热门问答' == $title) { $smallTitle = '回答'; $model = new Answer(); $view = 'view'; } elseif ('热门文章' == $title) { $smallTitle = '评论'; $model = new Articlecomment(); $view = 'viewart'; } else { $smallTitle = '评论'; $model = new Articlecomment(); $view = 'viewnote'; } ?> <div class="panel panel-default corner-radius"> <div class="panel-heading text-center"> <h3 class="panel-title"><?php echo $title; ?> </h3> </div> <div class="panel-body side-bar"> <ul class="list"> <?php
<?php use yii\helpers\Html; use yii\widgets\ActiveForm; use common\models\User; use app\models\Articlecomment; use yii\console\Markdown; /* @var $this yii\web\View */ /* @var $model app\models\Articlecomment */ /* @var $form yii\widgets\ActiveForm */ //,'placeholder'=>'回复XXX' if ($parId) { $username = Articlecomment::getCommentByParId($parId); $huifu = '回复' . $username; } else { $huifu = ''; $parId = 0; $username = ''; } ?> <div class="articlecomment-form"> <?php $form = ActiveForm::begin(['action' => ['/articlecomment/create']]); ?> <?php // Markdown::widget(['model' => $model, 'attribute' => 'body']) ?>