江湖家居至尊版官方演示站文章详情页,导航条不显示最终栏目前一个栏目,如图:
解决方法:打开 /themes/aj0527/article/detail.html 模板文件,在相应位置添加如下代码:
<!--面包屑导航开始-->
<div class="main_topnav mb20">
<div class="mainwd">
<p><span class="ico_list breadna"></span>您的位置:<a href="<{link ctl='index'}>"><{$CONFIG.site.title}></a> ><a href="<{link ctl='article'}>">学装修</a> ><a href="<{link ctl='article:items' arg0=$top_cate.cat_id}>"><{$top_cate.title}></a> <{if $top_cate.cat_id != $cate.cat_id}>
><a href="<{link ctl='article:items' arg0=$cate.cat_id}>"><{$cate.title}></a> <{/if}></p>
</div>
</div>
<!--面包屑导航结束-->
打开 system/home/controllers/article.ctl.php 文件,在函数 public function detail($article_id, $page=1) 中相应位置添加如下代码:
- $top_cate = $cate;
- $filter['cat_id'] = $cat_id;
- if($cate['level'] == 3){
- $this->pagedata['childrens'] = K::M('article/cate')->childrens($cate['parent_id']);
- }else{
- if($cat_ids = K::M('article/cate')->children_ids($cat_id)){
- $filter['cat_id'] = explode(',', $cat_ids);
- }
- if(!$childrens = K::M('article/cate')->childrens($cat_id)){
- if($cate['level']>1){
- $childrens = K::M('article/cate')->childrens($cate['parent_id']);
- }
- }
- $this->pagedata['childrens'] = $childrens;
- }
- if($cate['level']>1){
- $top_cate = K::M('article/cate')->cate($cate['parent_id']);
- }
- $this->pagedata['top_cate'] = $top_cate;
- $this->pagedata['cate'] = $cate;
-
复制代码
修改后,此段函数代码为:
- public function detail($article_id, $page=1)
- {
- if(!$article_id = (int)$article_id){
- $this->error(404);
- }else if(!$detail = K::M('article/article')->detail($article_id)){
- $this->error(404);
- }else if(!$cate = K::M('article/cate')->cate($detail['cat_id'])){
- $this->error(404);
- }else if(empty($detail['audit'])){
- $this->err->add('文章审核中,暂时不可访问', 211);
- }else if($detail['ontime'] && $detail['ontime'] > __TIME){
- $this->err->add('文章还未发布,暂时不可访问', 212);
- }else{
- K::M('article/article')->update_count($article_id, 'views', 1);
- if($detail['linkurl']){
- header("Location:".$detail['linkurl']);
- exit;
- }else if($detail['from'] != 'article'){
- $this->error(404);
- }else if($detail['city_id'] && ($detail['city_id'] != $this->request['city_id'])){
- $cfg = $this->system->config->get('site');
- if($cfg['multi_city'] && ($city = K::M('data/city')->city($detail['city_id']))){
- $this->system->response_code(301);
- header("Location:".$this->mklink("article:detail", array($article_id), null, $detail['city_id']));
- exit();
- }
- }
- if($page == 'all'){
- $curr_content = $detail['content'];
- }else{
- $page = max((int)$page, 1);
- $offset = $page - 1;
- if(!$curr_content = $detail['content_list'][$offset]){
- $this->error(404);
- }
- $detail['curr_content'] = $curr_content;
- }
- $pager = array('page'=>$page);
- $pager['count'] = $detail['content_count'];
- $pager['prev'] = K::M('article/article')->prev_item($article_id);
- $pager['next'] = K::M('article/article')->next_item($article_id);
- if($comment_list = K::M('article/comment')->items(array('article_id'=>$article_id, 'closed'=>0), array('comment_id'=>'DESC'), 1, 5)){
- $uids = array();
- foreach($comment_list as $k=>$v){
- $uids[$v['uid']] = $v['uid'];
- }
- if($uids){
- $this->pagedata['member_list'] = K::M('member/member')->items_by_ids($uids);
- }
- $this->pagedata['comment_list'] = $comment_list;
- }
- $access = $this->system->config->get('access');
- $this->pagedata['comment_yz'] = $access['verifycode']['comment'];
- $this->pagedata['pager'] = $pager;
- $top_cate = $cate;
- $filter['cat_id'] = $cat_id;
- if($cate['level'] == 3){
- $this->pagedata['childrens'] = K::M('article/cate')->childrens($cate['parent_id']);
- }else{
- if($cat_ids = K::M('article/cate')->children_ids($cat_id)){
- $filter['cat_id'] = explode(',', $cat_ids);
- }
- if(!$childrens = K::M('article/cate')->childrens($cat_id)){
- if($cate['level']>1){
- $childrens = K::M('article/cate')->childrens($cate['parent_id']);
- }
- }
- $this->pagedata['childrens'] = $childrens;
- }
- if($cate['level']>1){
- $top_cate = K::M('article/cate')->cate($cate['parent_id']);
- }
- $this->pagedata['top_cate'] = $top_cate;
- $this->pagedata['cate'] = $cate;
- $this->pagedata['detail'] = $detail;
- $seo = array('title'=>$detail['title'], 'article_desc'=>$detail['desc'], 'cate_title'=>$cate['title'], 'cate_name'=>$cate['title'], 'page'=>($page > 1) ? $page : '');
- $this->seo->init('article_detail', $seo);
- if($seo_title = $detail['seo_title']){
- $this->seo->set_title($seo_title);
- }
- if($seo_description = $detail['seo_description']){
- $this->seo->set_description($seo_description);
- }
- if($seo_keywords = $detail['seo_keywords']){
- $this->seo->set_keywords($seo_keywords);
- }
- $this->pagedata['mobile_url'] = $this->mklink('mobile/article:detail', array($article_id));
- $this->tmpl = 'article/detail.html';
- }
- }
复制代码
|
|