以前在用到5.7无限级栏目列表菜单时下载了网上的资料都未成功,因此我参考网上及dedecms本身的channel.lib.php及cattree.lib.php制作了调用标签。
1、在include\taglib建立randomartlist.lib.php
内容如下:
<?php
if(!defined('DEDEINC')) exit('Request Error!');
function lib_randomartlist(&$ctag, &$refObj)
{
global $dsql;
$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;
}
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("SELECT reid,topid,channeltype,ispart FROM `dede_arctype` WHERE reid='$topid' ");
if(!is_array($row2))
{
$typeid = $reid = $topid = $channeltype = $ispart = 0;
} else {
$reid = $row2['reid'];
$channeltype = $row2['channeltype'];
$ispart = $row2['ispart'];
$typepid = $row2['id'];
}
}
if( !empty($topid) )
{
$topQuery = "SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath FROM `dede_arctype` WHERE reid='$topid' And ishidden<>1 order by sortrank asc";
}
$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 .= " <li><a href='{$row['typelink']}'>{$row['typename']}</a></li>\n";
}
randomartlistSon($row['id'],$typeid,$currentstyle, $revalue);
}
if($cacheid !='') {
WriteCacheBlock($cacheid, $revalue);
}
return $revalue;
}
function randomartlistSon($id,$typeid,$currentstyle,&$revalue)
{
global $dsql;
$query = "SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath FROM `dede_arctype` WHERE reid='{$id}' And ishidden<>1 order by sortrank asc";
$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~",$row['rel'],$linkOkstr);
$linkOkstr = str_replace("~id~",$row['id'],$linkOkstr);
$linkOkstr = str_replace("~typelink~",$row['typelink'],$linkOkstr);
$linkOkstr = str_replace("~typename~",$row['typename'],$linkOkstr);
$thisv .= $linkOkstr;
}
else
{
$thisv .= " <li><a href='{$row['typelink']}'>{$row['typename']}</a></li>\n";
}
randomartlistSon($row['id'],$typeid,$currentstyle, $thisv);
}
if($thisv!='') $revalue .= " <ul>\n$thisv </ul>\n";
}
2、调用方式:
3、css方式:
本文标签:
声明:本文由代码号注册/游客用户【访烟】供稿发布,本站不对用户发布的织梦dedecms5.7无限级多级栏目菜单调用方法信息内容原创度和真实性等负责。如内容侵犯您的版权或其他权益,请留言并加以说明。站长审查之后若情况属实会及时为您删除。同时遵循 CC 4.0 BY-SA 版权协议,尊重和保护作者的劳动成果,转载请标明出处链接和本声明内容。本文作者:访烟» https://www.ebingou.cn/dmh/12820.html
很赞哦! (0)