织梦dedecms5.7 无限级多级栏目菜单调用方法

以前在用到5.7无限级栏目列表菜单时下载了网上的资料都未成功,因此我参考网上及dedecms本身的channel.lib.php及cattree.lib.php制作了调用标签。
1、在include\taglib建立randomartlist.lib.php
内容如下:
if(!defined('DEDEINC'))exit('RequestError!');

functionlib_randomartlist(&$ctag,&$refObj)
{
global$dsql;
//属性处理
//topid指定顶级树id,指定后,前一个属性将无效
$attlist="typeid|0,showall|,currentstyle|,cacheid|";
FillAttsDefault($ctag->CAttribute->Items,$attlist);
extract($ctag->CAttribute->Items,EXTR_SKIP);
$revalue='';
//读取固定的缓存块
$cacheid=trim($cacheid);
if($cacheid!=''){
$revalue=GetCacheBlock($cacheid);
if($revalue!='')return$revalue;
}
//如果属性里没指定栏目id,从引用类里获取栏目信息
if(empty($typeid))
{
if(isset($refObj->TypeLink->TypeInfos['id']))
{
$typeid=$refObj->TypeLink->TypeInfos['id'];
$reid=$refObj->TypeLink->TypeInfos['reid'];
$topid=$refObj->TypeLink->TypeInfos['topid'];
}
else{
$typeid=0;
}
}
else
{

$row2=$dsql->GetOne("SELECTreid,topid,channeltype,ispartFROM`dede_arctype`WHEREreid='$topid'");
if(!is_array($row2))
{
$typeid=$reid=$topid=$channeltype=$ispart=0;
}else{
$reid=$row2['reid'];
$channeltype=$row2['channeltype'];
$ispart=$row2['ispart'];
$typepid=$row2['id'];
}
}
//调用Typeid
if(!empty($topid))
{
$topQuery="SELECTid,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepathFROM`dede_arctype`WHEREreid='$topid'Andishidden<>1orderbysortrankasc";
}
$dsql->Execute('t',$topQuery);
while($row=$dsql->GetArray('t'))
{
$row['typelink']=GetOneTypeUrlA($row);
//处理同级栏目中,当前栏目的样式
if($row['id']==$typeid&&$currentstyle!='')
{
$linkOkstr=$currentstyle;
$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);
$revalue.=$linkOkstr;
}
else
{
$revalue.=" randomartlistSon($row['id'],$typeid,$currentstyle,$revalue);
}
if($cacheid!=''){
WriteCacheBlock($cacheid,$revalue);
}
return$revalue;
}

functionrandomartlistSon($id,&$revalue)
{
global$dsql;
$query="SELECTid,sitepathFROM`dede_arctype`WHEREreid='{$id}'Andishidden<>1orderbysortrankasc";
$dsql->Execute($id,$query);
$thisv='';
while($row=$dsql->GetArray($id))
{
$row['typelink']=GetOneTypeUrlA($row);
//处理同级栏目中,当前栏目的样式
if($row['id']==$typeid&&$currentstyle!='')
{
$linkOkstr=$currentstyle;
$linkOkstr=str_replace("~rel~",$linkOkstr);
$thisv.=$linkOkstr;
}
else
{
$thisv.=" }
if($thisv!='')$revalue.=" }

2、调用方式:

{dede:randomartlisttopid='12'currentstyle=" 3、css方式:
.alist{}
/*第一层修饰*/
.alistul{}
.alistulli{}
.alistullia{}
.alistullia:hover,.alistulli.thisclass{}
/*第二层修饰*/
.alistulliul{}
.alistulliulli{}
.alistulliullia{}
.alistulliullia:hover,.alistulliulli.thisclass{}

dawei

【声明】:淮南站长网内容转载自互联网,其相关言论仅代表作者个人观点绝非权威,不代表本站立场。如您发现内容存在版权问题,请提交相关链接至邮箱:bqsm@foxmail.com,我们将及时予以处理。