找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 1098|回复: 0

[分享] 解决dede 5.7 3J目录、侧导航的调用

[复制链接]
发表于 2018-7-22 10:01:41 | 显示全部楼层 |阅读模式 来自 中国–河南–新乡
1、找到 include/taglib/channel.lib.php 文件,用下面代码替换这个文件里面的所有内容,以免出错,请先备份一下原文件。
  (由于网页编码问题,复制了以后内容还不能直接用的。要注意里面的符号。)
  
  1. CAttribute->Items,$attlist);
  2.   extract($ctag->CAttribute->Items, EXTR_SKIP);
  3.   $innertext = $ctag->GetInnerText();
  4.   $cacheid = trim($cacheid);
  5.   if($cacheid !='') {
  6.   $likeType = GetCacheBlock($cacheid);
  7.   if($likeType != '') return $likeType;
  8.   }
  9.   $reid = 0;
  10.   $topid = 0;
  11.   if(empty($typeid) && $envs['typeid']!=0)
  12.   {
  13.   $typeid = $envs['typeid'];
  14.   $reid = $envs['reid'];
  15.   }else{
  16.   $reid=0;
  17.   }
  18.   if($type==''||$type=='sun') $type="son";
  19.   if($innertext=='') $innertext = GetSysTemplets("channel_list.htm");
  20.   if($reid==0 && $typeid>0)
  21.   {
  22.   $dbrow = $dsql->GetOne("Select reid From dede_arctype where id='$typeid' ");
  23.   if(is_array($dbrow)) $reid = $dbrow['reid'];
  24.   }
  25.   $likeType = '';
  26.   if($type=='top')
  27.   {
  28.   $sql = "Select id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath,description
  29.   From dede_arctype where reid=0 And ishidden<>1 order by sortrank asc limit 0,$row";
  30.   }
  31.   else if($type=="son")
  32.   {
  33.   //if($_sys_globals['typeid']>0) $typeid = $_sys_globals['typeid'];
  34.   if($typeid==0) {
  35.   return '';
  36.   }
  37.   $sql = "Select id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath,description
  38.   From dede_arctype where reid='$typeid' And ishidden<>1 order by sortrank asc limit 0,$row";
  39.   }
  40.   else if($type=="self")
  41.   {
  42.   if($reid==0) {
  43.   return '';
  44.   }
  45.   $sql = "Select id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath,description
  46.   From `dede_arctype` where reid='$reid' And ishidden<>1 order by sortrank asc limit 0,$row";
  47.   }
  48.   //And id<>'$typeid'
  49.   $needRel = false;
  50.   $dtp2 = new DedeTagParse();
  51.   $dtp2->SetNameSpace("field","[","]");
  52.   $dtp2->LoadSource($innertext);
  53.   $dsql2 = clone $dsql;
  54.   $dsql->SetQuery($sql);
  55.   $dsql->Execute();
  56.   $line = $row;
  57.   //检查是否有子栏目,并返回rel提示(用于二级菜单)
  58.   if(ereg(':rel', $innertext)) $needRel = true;
  59.   if(empty($sql)) return '';
  60.   $dsql->SetQuery($sql);
  61.   $dsql->Execute();
  62.   $totalRow = $dsql->GetTotalRow();
  63.   $GLOBALS['autoindex'] = 0;
  64.   for($i=0;$i < $line;$i++) { if($col>1) $likeType .= "
  65.   \r\n";
  66.   for($j=0;$j<$col;$j++) { if($col>1) $likeType .= "
  67.   \r\n";
  68.   if($row=$dsql->GetArray())
  69.   {
  70.   $row['sonids'] = $row['rel'] = '';
  71.   if($needRel)
  72.   {
  73.   $row['sonids'] = GetSonIds($row['id'], 0, false);
  74.   if($row['sonids']=='') $row['rel'] = '';
  75.   else $row['rel'] = " rel='dropmenu{$row['id']}'";
  76.   }
  77.   //处理同级栏目中,当前栏目的样式
  78.   if( ($row['id']==$typeid || ($topid==$row['id'] && $type=='top') ) && $currentstyle!='' )
  79.   {
  80.   if($currentstyle!='')
  81.   {
  82.   $linkOkstr = $currentstyle;
  83.   $row['typelink'] = GetOneTypeUrlA($row);
  84.   $linkOkstr = str_replace("~rel~",$row['rel'],$linkOkstr);
  85.   $linkOkstr = str_replace("~id~",$row['id'],$linkOkstr);
  86.   $linkOkstr = str_replace("~typelink~",$row['typelink'],$linkOkstr);
  87.   $linkOkstr = str_replace("~typename~",$row['typename'],$linkOkstr);
  88.   $likeType .= $linkOkstr;
  89.   }
  90.   }else
  91.   {
  92.   $row['typelink'] = $row['typeurl'] = GetOneTypeUrlA($row);
  93.   if(is_array($dtp2->CTags))
  94.   {
  95.   foreach($dtp2->CTags as $tagid=>$ctag){
  96.   if(isset($row[$ctag->GetName()]))
  97.   {
  98.   $dtp2->Assign($tagid,$row[$ctag->GetName()]);
  99.   }
  100.   elseif (preg_match('/^sonchannel[0-9]*$/',$ctag->GetName()))
  101.   {
  102.   $dtp2->Assign($tagid,lib_channel_son($ctag,$row['id'],$dsql2));
  103.   }
  104.   }
  105.   }
  106.   $likeType .= $dtp2->GetResult();
  107.   }
  108.   }
  109.   if($col>1) $likeType .= "
  110.   \r\n";
  111.   $GLOBALS['autoindex']++;
  112.   }//Loop Col
  113.   if($col>1)
  114.   {
  115.   $i += $col - 1;
  116.   $likeType .= "
  117.   \r\n";
  118.   }
  119.   }//Loop for $i
  120.   reset($dsql2);
  121.   $dsql->FreeResult();
  122.   return $likeType;
  123.   }
  124.   function lib_channel_son($ctag,$typeid = 0,$dsql2)
  125.   {
  126.   $attlist = "row|100,col|1,currentstyle|";
  127.   FillAttsDefault($ctag->CAttribute->Items,$attlist);
  128.   extract($ctag->CAttribute->Items, EXTR_SKIP);
  129.   $innertext = $ctag->GetInnerText();
  130.   $dsql3 = clone $dsql2;
  131.   $likeType = '';
  132.   //if($_sys_globals['typeid']>0) $typeid = $_sys_globals['typeid'];
  133.   if($typeid==0) {
  134.   return '';
  135.   }
  136.   $sql = "Select id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath,description
  137.   From dede_arctype where reid='$typeid' And ishidden<>1 order by sortrank asc limit 0,$row";
  138.   //And id<>'$typeid'
  139.   $dtp2 = new DedeTagParse();
  140.   $dtp2->SetNameSpace("field","[","]");
  141.   $dtp2->LoadSource($innertext);
  142.   $dsql2->SetQuery($sql);
  143.   $dsql2->Execute();
  144.   $line = $row;
  145.   for($i=0;$i < $line;$i++) { if($col>1) $likeType .= "
  146.   \r\n";
  147.   for($j=0;$j<$col;$j++) { if($col>1) $likeType .= "
  148.   \r\n";
  149.   if($row=$dsql2->GetArray())
  150.   {
  151.   $row['typelink'] = $row['typeurl'] = GetOneTypeUrlA($row);
  152.   if(is_array($dtp2->CTags))
  153.   {
  154.   foreach($dtp2->CTags as $tagid=>$ctag){
  155.   if(isset($row[$ctag->GetName()]))
  156.   {
  157.   $dtp2->Assign($tagid,$row[$ctag->GetName()]);
  158.   }
  159.   elseif (preg_match('/^sonchannel[0-9]*$/',$ctag->GetName()))
  160.   {
  161.   $dtp2->Assign($tagid,lib_channel_son($ctag,$row['id'],$dsql3));
  162.   }
  163.   }
  164.   }
  165.   $likeType .= $dtp2->GetResult();
  166.   }
  167.   if($col>1) $likeType .= "
  168.   \r\n";
  169.   }//Loop Col
  170.   if($col>1)
  171.   {
  172.   $i += $col - 1;
  173.   $likeType .= "
  174.   \r\n";
  175.   }
  176.   }//Loop for $i
  177.   reset($dsql3);
  178.   $dsql2->FreeResult();
  179.   return $likeType;
  180.   }
  181.   ?>
复制代码

2、将以下内容复制到你需要调用的模板中。
  Products List
  1.   //导航此处才开始
  2.   {dede:channelartlist typeid='top' row='8'}
  3.   {dede:field name='typename'/}
  4.   {dede:channel type='son'}//注意:此处不要加typeid函数,不然它会只调用你指定的ID分类;
  5.   [field:typename/]
  6.   [field:sonchannel0]
  7.   [field:typename/]
  8.   [field:sonchannel1]
  9.   ---[field:typename/]
  10.   [field:sonchannel2]
  11.   ===[field:typename/]
  12.   [field:sonchannel3]
  13.   ===[field:typename/]
  14.   [/field:sonchannel3]
  15.   [/field:sonchannel2]
  16.   [/field:sonchannel1]
  17.   [/field:sonchannel0]
  18.   {/dede:channel}
  19.   {/dede:channelartlist}
复制代码


//CSS样式,需要的拿去
  
  1. .l_nav{ width:240px;}
  2.   .l_title{ width:240px; padding-bottom:10px; background:url(../images/left_nav_bth.png) center bottom no-repeat; font-size:22px; color:#333; text-align:center; text-shadow: 0 1px #FFFFFF; font-weight:bold; margin-top: 20px;}
  3.   .l_nav a{ color:#555; text-decoration:none; line-height:25px;}
  4.   .l_nav li:hover { background:#f1f1f1; border:1px solid #fff; padding:4px 0 4px 9px;}
  5.   .l_nav li:hover a, .pright_l_nav li ul li:hover a{}
  6.   .l_nav li:hover ul a{ color:#333;}
  7.   .l_nav li ul li:hover a{ color:#fff; text-shadow:none;}
  8.   .l_nav li { width:200px; height:25px; padding:5px 0 5px 10px; text-shadow:0 1px #fff;}
  9.   .l_nav ul{ padding-left:20px; width:200px;}
  10.   .l_nav ul.nav2{ font-size:11px; padding-left:0px; position:absolute; margin-top:-2000px; margin-left:140px; background:#eee; box-shadow: 4px 4px 6px #999999; -moz-box-shadow: 4px 4px 6px #999999;}
  11.   .l_nav ul.nav2 li{ padding-left:10px; height:25px; list-style:none; margin-left:-5px; }
  12.   .l_nav ul.nav2 li:hover{ background:#333; padding-left:-5px; }
  13.   .l_nav li:hover ul.nav2{ margin-top:-30px; }
  14.   .pright_l_nav ul.nav2 li:hover a{ font-weight:bold;}
  15.   .pright_l_nav ul.nav3{ margin-top:-2000px; margin-left:140px; background:#999; }
  16.   .pright_l_nav ul.nav2 li:hover ul{ margin-top:-30px; padding-left:0;}
  17.   .pright_l_nav ul.nav3 li:hover{ margin-left:-5px; background:#000;}
复制代码

发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;

如何回报帮助你解决问题的坛友,好办法就是点击帖子下方的评分按钮给对方加【金币】不会扣除自己的积分,做一个热心并受欢迎的人!

▶专业解决各类DiscuzX疑难杂症、discuz版本升级 、网站搬家 和 云服务器销售!▶有偿服务QQ 860855665 更多精品应用
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则 需要先绑定手机号

关闭

站长推荐上一条 /1 下一条

QQ|侵权投诉|广告报价|手机版|小黑屋|西部数码代理|飘仙建站论坛 ( 豫ICP备2022021143号-1 )

GMT+8, 2025-1-31 20:52 , Processed in 0.053502 second(s), 9 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表