Exemplo n.º 1
0
 public function actionNews()
 {
     if ($_GET['id']) {
         $id = $_GET['id'];
     }
     $left = About::find()->asArray()->all();
     $category_id = \common\models\cms\Article::findOne(['id' => $id])->category_id;
     $category_name = \backend\models\Category::findOne(['id' => $category_id])->title;
     $infos = \common\models\cms\Article::findOne(['id' => $id]);
     return $this->render('index', compact("infos", "category_name", "left"));
 }
Exemplo n.º 2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = About::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, 'pai' => $this->pai, 'status' => $this->status]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'created_at', $this->created_at])->andFilterWhere(['like', 'updated_at', $this->updated_at]);
     return $dataProvider;
 }
Exemplo n.º 3
0
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model common\models\base\cms\About */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="about-form">

    <?php 
$form = ActiveForm::begin();
?>

    <?php 
echo $form->field($model, 'name')->textInput(['maxlength' => true]);
?>
    <?php 
echo $form->field($model, 'status')->dropDownList(\common\models\base\cms\About::getArrayStatus());
?>

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>

    <?php 
ActiveForm::end();
?>

</div>
Exemplo n.º 4
0
 public function actionHelp()
 {
     $left = About::find()->asArray()->all();
     try {
         $parent_id = Category::findOne(['title' => '帮助中心', 'status' => 1])->id;
         $infos = Article::find()->where(['category_id' => $parent_id, 'status' => 1]);
         $pages = new Pagination(['totalCount' => $infos->count(), 'pageSize' => '6']);
         $models = $infos->offset($pages->offset)->limit($pages->limit)->all();
     } catch (ErrorException $e) {
         $infos = '';
         $pages = '';
         $models = '';
     }
     return $this->render('help', compact("infos", "models", "pages", 'left'));
 }
Exemplo n.º 5
0
 /**
  * Finds the About model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return About the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = About::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }