コード例 #1
0
 public function actionAddarticle()
 {
     $user = new AdminUser();
     if (!$user->checkUserIsLogin()) {
         $this->redirect(Variable::$home_url);
         return;
     }
     $req = Yii::$app->request;
     //创建一个请求对象
     $form = new ArticleForm();
     $articleModel = new Article();
     $articleCatModel = ArticleCategory::find()->all();
     //添加
     $form->setScenario('create');
     if ($form->load($req->post()) && $form->validate()) {
         if ($articleModel->addAerticle($form->title, $form->keywords, $form->categoryId, $form->content, $form->status, $form->isTop, $form->description, $form->pic)) {
             $this->redirect(Variable::$articleManger_url);
             return;
         }
     }
     return $this->render(Variable::$addArticle_view, ['model' => $form, 'articleModel' => $articleModel, 'articleCatModel' => $articleCatModel]);
 }
コード例 #2
0
 public function actionArticlcat()
 {
     $user = new AdminUser();
     if (!$user->checkUserIsLogin()) {
         $this->redirect(Variable::$home_url);
         return;
     }
     $query = ArticleCategory::find();
     $pagination = new Pagination(['defaultPageSize' => 12, 'totalCount' => $query->count()]);
     $countries = $query->orderBy('addTime DESC')->offset($pagination->offset)->limit($pagination->limit)->all();
     return $this->render(Variable::$articleCat_view, ['countries' => $countries, 'pagination' => $pagination]);
 }