当前位置:首页 > 电脑知识 > 正文内容

干货分享(织梦栏目页模板)cms织梦教程,使用织梦CMS模板无限多级栏目调用详细教程方法,使用织梦CMS模板无限多级栏目调用详细教程方法,

sauo3年前 (2022-12-15)电脑知识102

在用到织梦CMS模板无限级栏目列表菜单时下载了网上的资料都未成功,因此我参考网上及dedecms本身的channel.lib.php及cattree.lib.php制作了调用标签。
在/include/taglib建立一个randomartlist.lib.php文件
内容如下:
<?phpif(!defined(DEDEINC))exit(Request Error!);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("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];}}//调用Typeidif(!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;}functionrandomartlistSon($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";}

前端调用代码:

<divclass="alist"><ul> {dede:randomartlist topid=12 current} <li><ahref="{dede:field name=typeurl/}"title="{dede:field name=typename/}">{dede:field name=typename/}</a></li> {/dede:randomartlist} </ul></div>

CSS样式:

.alist{}/*第一层修饰*/.alist ul {}.alist ul li {}.alist ul li a{}.alist ul li a:hover,.alist ul li .thisclass{}/*第二层修饰*/.alist ul li ul{}.alist ul li ul li{}.alist ul li ul li a{}.alist ul li ul li a:hover,.alist ul li ul li .thisclass{}
(window.slotbydup = window.slotbydup || []).push({ id: "u6835052", container: "_96bek913mdb", async: true });

本文链接:http://blog.sauo.top/?id=509 感谢分享!

分享到:

扫描二维码推送至手机访问。

版权声明:本文由冬眠先生个人博客发布,如需转载请注明出处。

本文链接:http://blog.sauo.top/?id=509

分享给朋友:

“干货分享(织梦栏目页模板)cms织梦教程,使用织梦CMS模板无限多级栏目调用详细教程方法,使用织梦CMS模板无限多级栏目调用详细教程方法,” 的相关文章

原创(禁止ping命令操作)linux如何停止ping,linux禁ping操作的方法,linux禁ping操作的方法,

免费领取腾讯云服务器! linux中可以通过ssh命令来禁止其它机器来ping自己,下面是配置方法,大家可以参考一下。 linux中禁ping的方法 方法1 临时禁ping,系统重启后失效,已在ubuntu系...

全程干货(查看php是否启动)查看php是否支持rar解压,查看php是ts版本还是nts版本的方法,查看php是ts版本还是nts版本的方法,

全程干货(查看php是否启动)查看php是否支持rar解压,查看php是ts版本还是nts版本的方法,查看php是ts版本还是nts版本的方法,

免费领取腾讯云服务器! 今天有用户来询问php的ts版本与php的nts版本的区别是什么,怎么去查看自己安装的php服务是ts版本还是nts版本,下面博文就来详细的说一下。 php ts版本与nts版本的区别 php官方提供...

没想到(PHP重定向)php获取重定向后的地址,php实现页面重定向的方法,php实现页面重定向的方法,

免费领取腾讯云服务器! php脚本实现页面重定向有多种方法,下面列几种简单的方法,供大家来参考一下。 php实现页面重定向的方法 方法1: 使用php中的 header() 函数来实现页面的跳转,实现重定向的...

干货分享(php输出json中文乱码)json数据中文乱码怎么办,解决 php json中文乱码的问题,解决 php json中文乱码的问题,

免费领取腾讯云服务器! php输出使用json_encode函数生成的json数据的时候,发现数据中的中文被转义成了unicode编码,如果使用ajax请求的json数据还好一点,浏览器会自动将unicode编码转义回来,但如果直接输出到浏览器上,那就会直...

不要告诉别人(php求数组交集)php数组取差集,php计算两个数组的交集与差集,php计算两个数组的交集与差集,

免费领取腾讯云服务器! php中计算两个数组之间的交集与差集可以使用 array_intersect() 与 array_diff() 数组处理函数,这两个数组的具体使用方法如下。 php计算两个数组之间的交集 array_...

发表评论

访客

看不清,换一张

◎欢迎参与讨论,请在这里发表您的看法和观点。