public function index()
 {
     global $G, $lang;
     $id = intval($_GET['id']);
     $this->id = $id;
     $this->t('post_title')->where(array('id' => $id))->update('viewnum=viewnum+1');
     $article = $this->t('post_title')->where(array('id' => $id))->selectOne();
     $article['tags'] = $article['tags'] ? unserialize($article['tags']) : array();
     if (!in_array($article['type'], array('image', 'video', 'music', 'goods', 'active'))) {
         $article['type'] = 'article';
     }
     $this->catid = $article['catid'];
     $content = $this->t('post_content')->where(array('aid' => $id, 'pageorder' => $G['page']))->selectOne();
     $articlecat = $this->t('category')->where(array('catid' => $article['catid']))->selectOne();
     $cat = new CategoryModel();
     $cat->catid = $this->catid;
     $siblings = $cat->fetchSiblings();
     $childs = $cat->fetchChilds();
     $patharray = $cat->fetchPathArray();
     $sitepath = $cat->getPath();
     $G['title'] = $article['title'] . ' - ' . $articlecat['cname'];
     $relateds = $this->fetchRelatedArticles();
     if ($article['type'] == 'article') {
         include template('detail_article');
     }
     if ($article['type'] == 'image') {
         $piclist = unserialize($content['content']);
         include template('detail_image');
     }
     if ($article['type'] == 'video') {
         $videocontent = unserialize($content['content']);
         include template('detail_video');
     }
     if ($article['type'] == 'goods') {
         $attributes = $this->t('post_goods_attribute')->where(array('aid' => $id))->select();
         include template('detail_goods');
     }
     if ($article['type'] == 'active') {
         $active = $this->t('post_active')->where(array('aid' => $id))->selectOne();
         include template('detail_active');
     }
 }
 public function index()
 {
     global $G, $lang;
     $pagesize = 20;
     $catid = intval($_GET['catid']);
     $where = array('catid' => $catid);
     $totalnum = M('post_title')->where($where)->count();
     $pagecount = $totalnum < $pagesize ? 1 : ceil($totalnum / $pagesize);
     $articlelist = M('post_title')->where($where)->page($G['page'], $pagesize)->select();
     if (is_array($articlelist) && !empty($articlelist)) {
         $newarticlelist = array();
         foreach ($articlelist as $list) {
             $list['pubtime'] = @date($G['setting']['dateformat'], $list['pubtime']);
             $list['modified'] = @date($G['setting']['dateformat'], $list['modified']);
             $newarticlelist[$list['id']] = $list;
         }
         $articlelist = $newarticlelist;
         unset($newarticlelist);
     } else {
         $articlelist = array();
     }
     $pages = $this->showPages($G['page'], $pagecount, "catid={$catid}", $totalnum);
     $category = $this->t('category')->where(array('catid' => $catid))->selectOne();
     $G['title'] = $category['cname'];
     $cat = new CategoryModel();
     $cat->catid = $catid;
     $sitepath = $cat->getPath();
     $category = $cat->getCategory();
     $sibling = $cat->fetchSiblings();
     $childs = $cat->fetchChilds();
     if ($category['template']) {
         include template($category['template']);
     } else {
         include template('list');
     }
 }