/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = MHelpdoc::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['helpdoc_id' => $this->helpdoc_id, 'sort' => $this->sort, 'visual' => $this->visual]); $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'content', $this->content])->andFilterWhere(['like', 'relate', $this->relate]); return $dataProvider; }
<?php echo $form->field($model, 'content')->widget(Widget::className(), ['settings' => ['lang' => 'zh_cn', 'minHeight' => 200, 'maxHeight' => 400, 'buttonSource' => true, 'convertDivs' => false, 'removeEmptyTags' => false, 'plugins' => ['clips', 'fullscreen', 'fontcolor', 'fontfamily', 'fontsize', 'limiter', 'table', 'textexpander', 'textdirection', 'video', 'definedlinks', 'filemanager', 'imagemanager'], 'imageManagerJson' => Url::to(['/helpdoc/imagesget']), 'imageUpload' => Url::to(['/helpdoc/imageupload'])]])->hint("为了在手机上显示美观,建议使用字体18px"); ?> <!-- <//?= $form->field($model, 'sort')->textInput() ?> --> <!-- <//?= $form->field($model, 'visual')->textInput() ?> --> <?php echo $form->field($model, 'visual')->dropDownList(MHelpdoc::getVisualOption()); ?> <?php echo $form->field($model, 'relate')->textInput(['maxlength' => 256])->hint("英文逗号分隔相关帮助文档编号,如:1,2,3,5,9 不要包含空格"); ?> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? '新增' : '修改', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div> <?php ActiveForm::end(); ?>
public function actionHelpdoc() { $this->layout = false; $gh_id = U::getSessionParam('gh_id'); $openid = U::getSessionParam('openid'); $helpdoc_id = $_GET['helpdoc_id']; $helpdoc = MHelpdoc::findOne(['helpdoc_id' => $helpdoc_id]); $helpdoc->sort = $helpdoc->sort + 1; $helpdoc->save(false); return $this->render('helpdoc', ['gh_id' => $gh_id, 'openid' => $openid, 'helpdoc' => $helpdoc]); }
/** * Finds the MHelpdoc model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return MHelpdoc the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = MHelpdoc::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
use app\models\MHelpdoc; /* @var $this yii\web\View */ /* @var $searchModel app\models\MHelpdocSearch */ /* @var $dataProvider yii\data\ActiveDataProvider */ $this->title = '帮助中心'; $this->params['breadcrumbs'][] = $this->title; ?> <div class="mhelpdoc-index"> <h1><?php echo Html::encode($this->title); ?> </h1> <?php // echo $this->render('_search', ['model' => $searchModel]); ?> <p> <?php echo Html::a('新增帮助文档', ['create'], ['class' => 'btn btn-success']); ?> </p> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => ['helpdoc_id', 'title', 'relate', 'sort', ['attribute' => 'visual', 'label' => '是否显示', 'value' => function ($model, $key, $index, $column) { return MHelpdoc::getVisualOption($model->visual); }, 'filter' => MHelpdoc::getVisualOption(), 'headerOptions' => array('style' => 'width:90px;')], ['class' => 'yii\\grid\\ActionColumn']]]); ?> </div>
</p> <p class="yuedu">阅读 <?php echo $helpdoc->sort; ?> </p> <ul class="table-view"> <?php if (!empty($helpdoc->relate)) { ?> <h5>查看相关问题</h5> <?php $relates = explode(",", $helpdoc->relate); foreach ($relates as $relate) { $hd = MHelpdoc::findOne(['visual' => 1, 'helpdoc_id' => $relate]); ?> <li class="table-view-cell"> <a data-ignore="push" class="navigate-right" href="<?php echo Url::to(['helpdoc', 'helpdoc_id' => $relate], true); ?> "> <?php echo $hd->title; ?> </a> </li> <?php }