コード例 #1
0
 public function actionMod()
 {
     $app = Yii::$app;
     $request = $app->request;
     $get = $request->get();
     $post = $request->post();
     $id = intval($get['id']);
     $article = Article::getArticle($id);
     if ($request->getIsPost()) {
         $article->load($post);
         $date = date('Y-m-d H:i:s', time());
         $article->modified_date = $date;
         $article->save();
         $this->refresh();
     } else {
         if ($article) {
             $this->smartyAssign('article', $article);
             $categoryList = Category::getCategoryList();
             $this->smartyAssign('categoryList', $categoryList);
             $this->showHtml();
         } else {
             $this->show404();
         }
     }
 }
コード例 #2
0
 public function actionArticle()
 {
     $app = Yii::$app;
     $request = $app->request;
     $get = $request->get();
     $alias = $get['alias'];
     $article = Article::getArticle($alias);
     if ($article && $article['status'] === 1) {
         static::smartyAssign('article', $article);
         $this->showHtml();
     } else {
         $this->show404();
     }
 }