"景先生毕设|www.jxszl.com

织梦教程:巧用sonchannel标签做三级菜单!

2022-10-29 16:40编辑: www.jxszl.com景先生毕设
导读:织梦怎么做III级菜单,这可能是很多人遇到过的问题,织梦确实不太好做III级菜单,今天AB织梦模板网就教大家I.招巧用sonchannel标签做III级菜单

关键字:织梦建站教程

作者:AB模板网

织梦教程

I..修改文件

 更多精彩就在: 51免费论文网|www.jxszl.com 
:include aglib目录下的channel.lib.php

functionlib_channel(&$ctag,&$refObj)
{
global$_sys_globals,$envs,$dsql;
$attlist="typeid|0,reid|0,row|I.00,col|I.,type|son,currentstyle|";
FillAttsDefault($ctag->CAttribute->Items,$attlist);
extract($ctag->CAttribute->Items,EXTR_SKIP);
$innertext=$ctag->GetInnerText();
$cacheid=trim($cacheid);
if($cacheid!=){
$likeType=GetCacheBlock($cacheid);
if($likeType!=)return$likeType;
}

$reid=0;
$topid=0;
if(empty($typeid)&&$envs[typeid]!=0)
{
$typeid=$envs[typeid];
$reid=$envs[reid];
}else{
$reid=0;
}
if($type==||$type==sun)$type="son";
if($innertext==)$innertext=GetSysTemplets("channel_list.htm");
if($reid==0&&$typeid>0)
{
$dbrow=$dsql->GetOne("SelectreidFromdede_arctypewhereid=$typeid");
if(is_array($dbrow))$reid=$dbrow[reid];
}
$likeType=;
if($type==top)
{
$sql="Selectid,typename,typedir,isdefault,ispart,defaultname,nameruleII,moresite,siteurl,sitepath,description
Fromdede_arctypewherereid=0Andishidden<>I.orderbysortrankasclimit0,$row";
}
elseif($type=="son")
{
//if($_sys_globals[typeid]>0)$typeid=$_sys_globals[typeid];
if($typeid==0){
return;
}
$sql="Selectid,typename,typedir,isdefault,ispart,defaultname,nameruleII,moresite,siteurl,sitepath,description
Fromdede_arctypewherereid=$typeidAndishidden<>I.orderbysortrankasclimit0,$row";
}
elseif($type=="self")
{
if($reid==0){
return;
}
$sql="Selectid,typename,typedir,isdefault,ispart,defaultname,nameruleII,moresite,siteurl,sitepath,description
From`dede_arctype`wherereid=$reidAndishidden<>I.orderbysortrankasclimit0,$row";
}
//Andid<>$typeid
$needRel=false;
$dtpII=newDedeTagParse();
$dtpII->SetNameSpace("field","[","]");
$dtpII->LoadSource($innertext);
$dsqlII=clone$dsql;
$dsql->SetQuery($sql);
$dsql->Execute();
$line=$row;
//检查是否有子栏目,并返回rel提示(用于II级菜单)
if(ereg(:rel,$innertext))$needRel=true;

if(empty($sql))return;
$dsql->SetQuery($sql);
$dsql->Execute();

$totalRow=$dsql->GetTotalRow();
$GLOBALS[autoindex]=0;
for($i=0;$i<$line;$i++)
{
if($col>I.)$likeType.="
";
for($j=0;$j<$col;$j++)
{
if($col>I.)$likeType.="
";
if($row=$dsql->GetArray())
{
$row[sonids]=$row[rel]=;
if($needRel)
{
$row[sonids]=GetSonIds($row[id],0,false);
if($row[sonids]==)$row[rel]=;
else$row[rel]="rel=dropmenu{$row[id]}";
}
//处理同级栏目中,当前栏目的样式
if(($row[id]==$typeid||($topid==$row[id]&&$type==top))&&$currentstyle!=)
{
if($currentstyle!=)
{
$linkOkstr=$currentstyle;
$row[typelink]=GetOneTypeUrlA($row);
$linkOkstr=str_replace("~rel~",$row[rel],$linkOkstr);
$linkOkstr=str_replace("~id~",$row[id],$linkOkstr);
$linkOkstr=str_replace("~typelink~",$row[typelink],$linkOkstr);
$linkOkstr=str_replace("~typename~",$row[typename],$linkOkstr);
$likeType.=$linkOkstr;
}
}else
{
$row[typelink]=$row[typeurl]=GetOneTypeUrlA($row);
if(is_array($dtpII->CTags))
{
foreach($dtpII->CTagsas$tagid=>$ctag){
if(isset($row[$ctag->GetName()]))
{
$dtpII->Assign($tagid,$row[$ctag->GetName()]);
}
elseif(preg_match(/^sonchannel[0-IX]*$/,$ctag->GetName()))
{
$dtpII->Assign($tagid,lib_channel_son($ctag,$row[id],$dsqlII));
}
}
}
$likeType.=$dtpII->GetResult();
}
}
if($col>I.)$likeType.="
";
$GLOBALS[autoindex]++;
}//LoopCol
if($col>I.)
{
$i+=$col-I.;
$likeType.="
";
}
}//Loopfor$i
reset($dsqlII);
$dsql->FreeResult();
return$likeType;
}
functionlib_channel_son($ctag,$typeid=0,$dsqlII)
{
$attlist="row|I.00,col|I.,currentstyle|";
FillAttsDefault($ctag->CAttribute->Items,$attlist);
extract($ctag->CAttribute->Items,EXTR_SKIP);
$innertext=$ctag->GetInnerText();
$dsqlIII=clone$dsqlII;
$likeType=;
//if($_sys_globals[typeid]>0)$typeid=$_sys_globals[typeid];
if($typeid==0){
return;
}
$sql="Selectid,typename,typedir,isdefault,ispart,defaultname,nameruleII,moresite,siteurl,sitepath,description
Fromdede_arctypewherereid=$typeidAndishidden<>I.orderbysortrankasclimit0,$row";
//Andid<>$typeid
$dtpII=newDedeTagParse();
$dtpII->SetNameSpace("field","[","]");
$dtpII->LoadSource($innertext);
$dsqlII->SetQuery($sql);
$dsqlII->Execute();
$line=$row;
for($i=0;$i<$line;$i++)
{
if($col>I.)$likeType.="
";
for($j=0;$j<$col;$j++)
{
if($col>I.)$likeType.="
";
if($row=$dsqlII->GetArray())
{
$row[typelink]=$row[typeurl]=GetOneTypeUrlA($row);
if(is_array($dtpII->CTags))
{
foreach($dtpII->CTagsas$tagid=>$ctag){
if(isset($row[$ctag->GetName()]))
{
$dtpII->Assign($tagid,$row[$ctag->GetName()]);
}
elseif(preg_match(/^sonchannel[0-IX]*$/,$ctag->GetName()))
{
$dtpII->Assign($tagid,lib_channel_son($ctag,$row[id],$dsqlIII));
}
}
}
$likeType.=$dtpII->GetResult();
}
if($col>I.)$likeType.="
";
}//LoopCol
if($col>I.)
{
$i+=$col-I.;
$likeType.="
";
}
}//Loopfor$i
reset($dsqlIII);
$dsqlII->FreeResult();
return$likeType;
}
?>

复制这个文件覆盖旧文件.

II:巧用sonchannel标签做III级菜单

{dede:channelartlisttypeid=VIIII}

{/dede:channelartlist}//调用顶级栏目(I.级菜单)

dede:channeltype=son}

{/dede:channel}//II级菜单

[field:sonchannel0]//无限获取III级菜单

实例:

divclass="nav">

顶级菜单


{dede:channelartlisttypeid=VIIII}

{dede:fieldname=typename/}

{/dede:channelartlist}





{dede:channelartlisttypeid=VIIII}






{dede:channeltype=son}




[field:typename/]




[field:sonchannel0][field:typename/]|[/field:sonchannel0]





{/dede:channel}



{/dede:channelartlist}



注:这里顶级菜单我调用了两次,大家按照自己的需求来!


原文链接:http://www.jxszl.com/biancheng/dedecms/76233.html
最新推荐
热门阅读
随机阅读