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

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

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

在用到织梦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模板无限多级栏目调用详细教程方法,” 的相关文章

新鲜出炉(ubuntu系统与centos系统区别)ubuntu还是centos,centos系统与ubuntu系统的区分,centos系统与ubuntu系统的区分,

免费领取腾讯云服务器! Linux的发行版有很多,而我们经常使用的为centos与ubuntu,下面这篇博文就说说这两个系统的发源与区别。 CentOS CentOS(Community Enterprise Operati...

这都可以?(php获取服务器信息)php获取客户端,php获取服务器操作系统类型的方法,php获取服务器操作系统类型的方法,

免费领取腾讯云服务器! 利用php脚本中的 php_uname() 函数与 PHP_OS 变量可以获取服务器操作系统的类型,具体的使用方法如下。 php获取服务器操作系统的方法 1、php_uname() 获取服务器操作系统...

一篇读懂(PHP for循环)php跳出循环的语句,php中的几种循环语句,php中的几种循环语句,

免费领取腾讯云服务器! 列举几种php脚本中常用的几种循环语句,比如,for,foreach,do....while 等。 php for循环 for循环在很多语言中都经常用到,比如js语言,c语言,java语言等。...

这都可以(判断是否是ajax请求)php判断请求方式,php判断是否为ajax请求的方法,php判断是否为ajax请求的方法,

免费领取腾讯云服务器! 在后端可以利用php代码来判断前台提交的数据是否通过ajax进行提交的,其方法也非常的简单,只需要判断$_SERVER["HTTP_X_REQUESTED_WITH"] 是否存在,以及判断 $_SERVER["HTTP_X_REQU...

全程干货(php将图片转为对象)php文件怎么转成图片,php将图片转为base64编码格式图片的方法,php将图片转为base64编码格式图片的方法,

免费领取腾讯云服务器! 下面的博文提供两个利用php代码将图片转为base64编码格式图片的方法,分为php转换本地图片为base64图片以及php转换远程图片为base64图片的方法。...

深度揭秘(Linux查看文件md5)linux命令查看md5值,Linux系统下查看文件md5的方法,Linux系统下查看文件md5的方法,

深度揭秘(Linux查看文件md5)linux命令查看md5值,Linux系统下查看文件md5的方法,Linux系统下查看文件md5的方法,

免费领取腾讯云服务器! 上两篇博文,分别写了在window系统下获取文件md5值的方法与mac苹果系统下获取文件md5值的方法,今天这篇博文就写一下在linux系统下获取文件md5值的方法。 Linux系统下获取文件md5值的方法...

发表评论

访客

看不清,换一张

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