热搜词
发表于 2017-8-1 18:24:54 | 显示全部楼层 |阅读模式
江湖家居至尊版官方演示站文章详情页,导航条不显示最终栏目前一个栏目,如图:
01.png


解决方法:打开 /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) 中相应位置添加如下代码:

  1.      $top_cate = $cate;
  2.             $filter['cat_id'] = $cat_id;
  3.             if($cate['level'] == 3){
  4.                 $this->pagedata['childrens'] = K::M('article/cate')->childrens($cate['parent_id']);
  5.             }else{
  6.                 if($cat_ids = K::M('article/cate')->children_ids($cat_id)){
  7.                     $filter['cat_id'] = explode(',', $cat_ids);
  8.                 }
  9.                 if(!$childrens = K::M('article/cate')->childrens($cat_id)){
  10.                     if($cate['level']>1){
  11.                         $childrens = K::M('article/cate')->childrens($cate['parent_id']);
  12.                     }                  
  13.                 }
  14.                 $this->pagedata['childrens'] = $childrens;               
  15.             }
  16.             if($cate['level']>1){
  17.                 $top_cate = K::M('article/cate')->cate($cate['parent_id']);
  18.             }
  19.             $this->pagedata['top_cate'] = $top_cate;
  20.             $this->pagedata['cate'] = $cate;
  21.                         
复制代码

修改后,此段函数代码为:

  1.     public function detail($article_id, $page=1)
  2.     {
  3.         if(!$article_id = (int)$article_id){
  4.             $this->error(404);
  5.         }else if(!$detail = K::M('article/article')->detail($article_id)){
  6.             $this->error(404);
  7.         }else if(!$cate = K::M('article/cate')->cate($detail['cat_id'])){
  8.             $this->error(404);
  9.         }else if(empty($detail['audit'])){
  10.             $this->err->add('文章审核中,暂时不可访问', 211);
  11.         }else if($detail['ontime'] && $detail['ontime'] > __TIME){
  12.             $this->err->add('文章还未发布,暂时不可访问', 212);
  13.         }else{
  14.             K::M('article/article')->update_count($article_id, 'views', 1);
  15.             if($detail['linkurl']){
  16.                 header("Location:".$detail['linkurl']);
  17.                 exit;
  18.             }else if($detail['from'] != 'article'){
  19.                 $this->error(404);
  20.             }else if($detail['city_id'] && ($detail['city_id'] != $this->request['city_id'])){
  21.                 $cfg = $this->system->config->get('site');
  22.                 if($cfg['multi_city'] && ($city = K::M('data/city')->city($detail['city_id']))){
  23.                     $this->system->response_code(301);
  24.                     header("Location:".$this->mklink("article:detail", array($article_id), null, $detail['city_id']));
  25.                     exit();
  26.                 }
  27.             }
  28.             if($page == 'all'){
  29.                 $curr_content = $detail['content'];
  30.             }else{
  31.                 $page = max((int)$page, 1);
  32.                 $offset = $page - 1;
  33.                 if(!$curr_content = $detail['content_list'][$offset]){
  34.                     $this->error(404);
  35.                 }
  36.                 $detail['curr_content'] = $curr_content;
  37.             }
  38.             $pager = array('page'=>$page);
  39.             $pager['count'] = $detail['content_count'];
  40.             $pager['prev'] = K::M('article/article')->prev_item($article_id);
  41.             $pager['next'] = K::M('article/article')->next_item($article_id);
  42.             if($comment_list = K::M('article/comment')->items(array('article_id'=>$article_id, 'closed'=>0), array('comment_id'=>'DESC'), 1, 5)){
  43.                 $uids = array();
  44.                 foreach($comment_list as $k=>$v){
  45.                     $uids[$v['uid']] = $v['uid'];
  46.                 }
  47.                 if($uids){
  48.                     $this->pagedata['member_list'] = K::M('member/member')->items_by_ids($uids);
  49.                 }
  50.                 $this->pagedata['comment_list'] = $comment_list;
  51.             }
  52.                         $access = $this->system->config->get('access');
  53.                         $this->pagedata['comment_yz'] = $access['verifycode']['comment'];
  54.             $this->pagedata['pager'] = $pager;
  55. $top_cate = $cate;
  56.             $filter['cat_id'] = $cat_id;
  57.             if($cate['level'] == 3){
  58.                 $this->pagedata['childrens'] = K::M('article/cate')->childrens($cate['parent_id']);
  59.             }else{
  60.                 if($cat_ids = K::M('article/cate')->children_ids($cat_id)){
  61.                     $filter['cat_id'] = explode(',', $cat_ids);
  62.                 }
  63.                 if(!$childrens = K::M('article/cate')->childrens($cat_id)){
  64.                     if($cate['level']>1){
  65.                         $childrens = K::M('article/cate')->childrens($cate['parent_id']);
  66.                     }                  
  67.                 }
  68.                 $this->pagedata['childrens'] = $childrens;               
  69.             }
  70.             if($cate['level']>1){
  71.                 $top_cate = K::M('article/cate')->cate($cate['parent_id']);
  72.             }
  73.             $this->pagedata['top_cate'] = $top_cate;
  74.             $this->pagedata['cate'] = $cate;
  75.             $this->pagedata['detail'] = $detail;
  76.             $seo = array('title'=>$detail['title'], 'article_desc'=>$detail['desc'], 'cate_title'=>$cate['title'], 'cate_name'=>$cate['title'], 'page'=>($page > 1) ? $page : '');
  77.             $this->seo->init('article_detail', $seo);
  78.             if($seo_title = $detail['seo_title']){
  79.                 $this->seo->set_title($seo_title);
  80.             }
  81.             if($seo_description = $detail['seo_description']){
  82.                 $this->seo->set_description($seo_description);
  83.             }
  84.             if($seo_keywords = $detail['seo_keywords']){
  85.                 $this->seo->set_keywords($seo_keywords);
  86.             }
  87.             $this->pagedata['mobile_url'] = $this->mklink('mobile/article:detail', array($article_id));
  88.             $this->tmpl = 'article/detail.html';
  89.         }        
  90.     }
复制代码



全部评论0
回复
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|手机版|小黑屋|管理员之家 ( 苏ICP备2023053177号-2 )

GMT+8, 2024-7-4 01:10 , Processed in 0.201879 second(s), 25 queries .

Powered by Discuz! X3.5

Cpoyright © 2001-2024 Discuz! Team