织梦模板dedecms5.7 无限级多级栏目菜单调用教程
以前在用到织梦模板无限级栏目列表菜单时下载了网上的资料都未成功,因此我参考网上及dedecms本身的channel.lib.php及cattree.lib.php制作了调用标签。
1、在includetaglib建立randomartlist.lib.php
内容如下:
01
<?php
02
if(!defined('DEDEINC')) exit('Request Error!');
03
function lib_randomartlist(&$ctag, &$refObj)
04
{
05
global $dsql;
06
//属性处理
07
//topid 指定顶级树 id ,指定后,前一个属性将无效
08
$attlist="typeid|0,showall|,currentstyle|,cacheid|";
09
FillAttsDefault($ctag->CAttribute->Items,$attlist);
10
extract($ctag->CAttribute->Items, EXTR_SKIP);
11
$revalue = '';
12
//读取固定的缓存块
13
$cacheid = trim($cacheid);
14
if($cacheid !='') {
15
$revalue = GetCacheBlock($cacheid);
16
if($revalue != '') return $revalue;
17
}
//如果属性里没指定栏目id,从引用类里获取栏目信息
001
if(empty($typeid))
002
{
003
if( isset($refObj->TypeLink->TypeInfos['id']) )
004
{
005
$typeid = $refObj->TypeLink->TypeInfos['id'];
006
$reid = $refObj->TypeLink->TypeInfos['reid'];
007
$topid = $refObj->TypeLink->TypeInfos['topid'];
008
}
009
else {
010
$typeid = 0;
011
}
012
}
013
else
014
{
015
$row2 = $dsql->GetOne("SELECT reid,topid,channeltype,ispart FROM `dede_arctype` WHERE reid='$topid' ");
016
if(!is_array($row2))
017
{
018
$typeid = $reid = $topid = $channeltype = $ispart = 0;
019
} else {
020
$reid = $row2['reid'];
021
$channeltype = $row2['channeltype'];
022
$ispart = $row2['ispart'];
023
$typepid = $row2['id'];
024
}
025
}
026
//调用Typeid
027
if( !empty($topid) )
028
{
029
$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";
030
}
031
$dsql->Execute('t', $topQuery);
032
while($row = $dsql->GetArray('t'))
033
{
034
$row['typelink'] = GetOneTypeUrlA($row);
035
//处理同级栏目中,当前栏目的样式
036
if( $row['id']==$typeid && $currentstyle!='' )
037
{
038
$linkOkstr = $currentstyle;
039
$linkOkstr = str_replace("~rel~",$row['rel'],$linkOkstr);
040
$linkOkstr = str_replace("~id~",$row['id'],$linkOkstr);
041
$linkOkstr = str_replace("~typelink~",$row['typelink'],$linkOkstr);
042
$linkOkstr = str_replace("~typename~",$row['typename'],$linkOkstr);
043
$revalue .= $linkOkstr;
044
}
045
else
046
{
047
$revalue .= " <li><a href='{$row['typelink']}'>{$row['typename']}</a></li>n";
上一篇:dedecms实现任意页面调用当前会员信息的方法
下一篇:织梦CMS内容摘要字数限制不能自动换行
相关仿站教程:
仿站咨询扫二维码


仿站教程推荐
- 相关链接:
- 教程说明:
织梦模板dedecms5.7 无限级多级栏目菜单调用教程
。