Example #1
0
 /**
  * 文章首页
  */
 public function articleAction($name)
 {
     $name = htmlspecialchars($name);
     $leve = $this->navall["{$name}"]['leve'];
     $list = new ListModel();
     if ($leve == 1) {
         //获取当前一级栏目的ID
         $id = $list->get('category', ['catid', 'catname', 'catpath', 'description', 'keyword'], ['catpath' => $name]);
         $id['title'] = str_replace(',', "_", $id['keyword']);
         //导航位置标签
         $nav = $list->nav($name);
         //首页内容数据
         $catlist = $list->detail($id['catid']);
         //友情链接
         $friendurl = "<li><a href='/{$name}/'>";
         $friendurl .= str_replace(',', "</a></li><li><a href=/{$name}/ >", $id['keyword']);
         $friendurl .= '</a></li>';
         $this->getView()->assign('id', $id);
         $this->getView()->assign('catlist', $catlist);
         $this->getView()->assign('nav', $nav);
         $this->getView()->assign('friendurl', $friendurl);
     } elseif (empty($leve)) {
         $catid = $this->navall["{$name}"];
         if (!empty($catid)) {
             $page = intval($_GET['page']);
             $catid['title'] = str_replace(',', "_", $catid['keyword']);
             //获取文章的总数
             $total = $list->count('news', ['catid' => $catid['catid']]);
             //---------------------------------------------二级导航位置标签没有
             $num = ceil($total / 24);
             //友情链接
             $friendurl = "<li><a href='/{$name}/'>";
             $friendurl .= str_replace(',', "</a></li><li><a href=/{$name}/ >", $catid['keyword']);
             $friendurl .= '</a></li>';
             //文章列表
             $conlist = $list->conlist($catid['catid'], $total, $page, 24);
             for ($i = 0; $i < count($conlist); $i++) {
                 $conlist[$i]['url'] = "/{$name}/{$conlist[$i]['id']}.html";
             }
             //文章分页
             $listpage = $list->listpage($name, null, $total, $page, 24);
             //获取当前栏目随机11篇文章
             $article = $list->rand_news($catid['catid'], 11);
             //最新的30条文章
             $article_s = $list->new_article(30);
         }
         $this->getView()->assign('conlist', $conlist);
         $this->getView()->assign('total', $total);
         $this->getView()->assign('num', $num);
         $this->getView()->assign('article', $article);
         $this->getView()->assign('page', $page);
         $this->getView()->assign('friendurl', $friendurl);
         $this->getView()->assign('article_s', $article_s);
         $this->getView()->assign('catkey', $this->numnavall);
         $this->getView()->assign('catid', $catid);
         $this->getView()->assign('listpage', $listpage);
         $this->getView()->display('./list/notwolist.phtml');
         exit;
     }
 }