/** * 文章详情页 */ public function detailsAction($name, $path = null, $id = null) { $list = new ListModel(); if ($id == false) { $id = $path; } //获取当前一级栏目 // $oname = $list->get('category',['catid','catname','catpath','description','keyword'],['catpath' => $name]); //获取当前二级栏目 // $tname = $list->get('category',['catid','catname','catpath','keyword'],['AND'=>['parentid'=>$oname['catid'],'catpath' => $path]]); //获取文章标题 $title = $list->get('news', ['id', 'catid', 'title', 'keywords', 'description', 'inputtime'], ['id' => $id]); $tname = $this->numnavall[$title['catid']]; if (empty($tname)) { misc::show404(); } $two_id = $tname['catid']; //友情链接 $friendurl = "<li><a href=/{$tname['name']}>"; $friendurl .= str_replace(',', "</a></li><li><a href={$tname['name']} >", $tname['keyword']); $friendurl .= '</a></li>'; //如果是二级栏目下的文章获取二级栏目的相关信息 if ($tname['parentid'] != 0) { $oname = $this->numnavall[$tname['parentid']]; //二级导航位置标签 $nav = $list->nav($oname['catid']); //获取当前一级栏目的所有二级栏目catid $two_id = $list->getid($tname['parentid']); //友情链接 $friendurl = "<li><a href={$oname['name']}>"; $friendurl .= str_replace(',', "</a></li><li><a href={$oname['name']} >", $oname['keyword']); $friendurl .= '</a></li>'; } $title['keywords'] = str_replace(' ', ',', $title['keywords']); if (empty($title['keywords'])) { $title['keywords'] = $title['title']; } if (!empty($title)) { //获取文章主体内容 $content = $list->get('news_data', ['id', 'content'], ['id' => $id]); //截取P标签 $str = "<P style=" . '\\"' . 'color:#FFFFFF' . '\\">'; $num = strpos($content['content'], $str); if ($num) { $content['content'] = substr($content['content'], 0, $num); } //当前栏目下的最新文章 $two_title = $list->select('news', ['id', 'title'], ['catid' => $tname['catid'], "ORDER" => "inputtime DESC", "LIMIT" => 9]); //最新的30条文章 $article_s = $list->new_article(30); //最新的栏目的文章 $one_content = $list->one_content($two_id, 10); $this->getView()->assign('title', $title); $this->getView()->assign('content', $content); $this->getView()->assign('catkey', $this->numnavall); $this->getView()->assign('article_s', $article_s); $this->getView()->assign('friendurl', $friendurl); $this->getView()->assign('two_title', $two_title); $this->getView()->assign('one_content', $one_content); $this->getView()->assign('oname', $oname); $this->getView()->assign('tname', $tname); $this->getView()->assign('nav', $nav); } }