/** * 文章列表页 */ public function listAction($name, $path = null) { $list = new ListModel(); $page = intval($_GET['page']); //获取当前一级栏目的ID $oname = $list->get('category', ['catid', 'catname', 'catpath'], ['catpath' => $name]); //获取当前二级栏目的ID $catid = $list->get('category', ['catid', 'catname', 'catpath', 'description', 'keyword'], ['AND' => ['parentid' => $oname['catid'], 'catpath' => $path]]); if (!empty($catid)) { $catid['title'] = str_replace(',', "_", $catid['keyword']); //获取文章的总数 $total = $list->count('news', ['catid' => $catid['catid']]); //二级导航位置标签 $nav = $list->nav($name); //最大页数 $num = ceil($total / 24); //友情链接 $friendurl = "<li><a href='/{$name}/{$path}/'>"; $friendurl .= str_replace(',', "</a></li><li><a href=/{$name}/{$path}/ >", $catid['keyword']); $friendurl .= '</a></li>'; //获取URL时用 // $list->shujuurl($catid['catid'],$name,$path); //文章列表 $conlist = $list->conlist($catid['catid'], $total, $page, 24); //文章分页 $listpage = $list->listpage($name, $path, $total, $page, 24); for ($i = 0; $i < count($conlist); $i++) { $conlist[$i]['url'] = "/{$name}/{$path}/{$conlist[$i]['id']}.html"; } //获取一级栏目最新的文章 $array = array(array('Disease' => $oname['catname'], 'catid' => $oname['catid'])); //获取列表页二级栏目的前11条文章 $article = $list->Article($array, 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('oname', $oname); $this->getView()->assign('tname', $catid); $this->getView()->assign('listpage', $listpage); $this->getView()->assign('nav', $nav); } }