Example #1
0
 public function categoryAction($args = null)
 {
     global $tpl, $app;
     try {
         if (!isset($args['slug']) || !isset($this->categories[trim($args['slug'])])) {
             throw new Exception('分类不能为空或分类不存在');
         }
         $page = new Page();
         $page->Page = $args['page'];
         $page->Url = SITE_URL . 'category/' . trim($args['slug']) . '/';
         $page->Condition = '/';
         //$category = new Category('slug', trim($args['slug']));
         $category = $this->categories[trim($args['slug'])];
         $result = Article::findByCid($category->id, $page);
         $page->Count = $result['count'];
     } catch (Exception $e) {
         //die($e->getMessage());
         $app->error($e->getMessage(), SITE_URL);
     }
     $tpl->assign('post_list', $result['res']);
     $tpl->assign('category', $category->name);
     $tpl->assign('page_nav', $page->getPage());
     $tpl->display(DEFAULT_TEMPLATE . '/list.html');
 }