VPS参考测评推荐
专注分享VPS主机优惠信息
衡天云优惠活动

如何在DEDECMS中获得无限列子类别

主机参考:VPS测评参考推荐/专注分享VPS服务器优惠信息!若您是商家可以在本站进行投稿,查看详情!此外我们还提供软文收录、PayPal代付、广告赞助等服务,查看详情!
我们发布的部分优惠活动文章可能存在时效性,购买时建议在本站搜索商家名称可查看相关文章充分了解该商家!若非中文页面可使用Edge浏览器同步翻译!PayPal代付/收录合作

如何在DEDECMS中获得无限列子类别

如何在dedecms中获得无限列子类别?

DeDeecms主要用于制作公司网站。今天,在为客户设计网站时,在DEDE自动内部链接和URL拼写格式固定后,我们遇到了一个小问题,因为产品分类最多有四个级别,客户需要在左侧的弹出菜单中调用所有级别的子分类,而Deecms默认只能调用一级分类。经过努力,百度+谷歌+自己的头终于得到了这个东西,不敢独自享受它,并将其发送给有需要的朋友分享。

推荐学习:梦想编织cms

首先,将/include/taglib/channer l . lib . PHP文件的代码修改如下:

代码如下:

& lt?php函数lib _ channel(& amp;$ ctag & amp;$ ref obj){ global $ _ sys _ globals,$envs,$ dsql$ attlist =“typeid | 0,reid|0,row|100,col|1,type|son,current style |“;FillAttsDefault($ ctag-& gt;属性-& gt;Items,$ attlist);提取($ ctag-》;属性-& gt;Items,EXTR _ SKIP);$ innertext = $ ctag-& gt;GetInnerText();if(empty($ typeid)& amp;& amp$ envs【& amp;#39;typeid & amp#39;]!= 0){ $ typeid = $ envs【& amp;#39;typeid & amp#39;];$ Reid = $ envs【& amp;#39;里德& amp#39;];} else { $ Reid = 0;} if($ type = =“| | $ type = =‘sun’)$ type =“son“;if($ inner text = =“)$ inner text = GetSysTemplets(“channel _ list . htm“);if($ Reid = = 0 & amp;& amp$ typeid & gt0){ $ dbrow = $ dsql-& gt;get one(“Select Reid From ying _ arctype where id =‘$ typeid‘“);if(is _ array($ dbrow)$ Reid = $ dbrow【& amp;#39;里德& amp#39;];} $ likeType =“;if($ type = =‘top‘){ $ SQL =“Select id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath,description From ying_arctype其中reid=0和ishidden & lt& gt1 order by sortrank asc limit 0,$ row“;} else if($ type = =“son“){//if($ _ sys _ globals【& amp;#39;typeid & amp#39;】& gt0)$ typeid = $ _ sys _ globals【& amp;#39;typeid & amp#39;];if($ typeid = = 0){ return“;} $ SQL =“Select id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath,description From ying_arctype其中Reid =‘$ typeid‘和ishidden & lt& gt1 order by sortrank asc limit 0,$ row“;} else if($ type = =“self“){ if($ Reid = = 0){ return“;} $ SQL =“Select id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath,description From‘ying _ arctype‘其中Reid =‘$ Reid‘和ishidden & lt& gt1 order by sortrank asc limit 0,$ row“;}//和id & lt& gt$ typeid‘$ DTP 2 = new DedeTagParse();$ DTP 2-& gt;set namespace(“field“,“【& quot,& quot]");$ DTP 2-& gt;load source($ innertext);$ dsql2 = clone $ dsql$ dsql-& gt;SetQuery($ SQL);$ dsql-& gt;execute();$ line = $ row$ GLOBALS【& amp;#39;自动索引& amp#39;] = 0;for($ I = 0;$ i & lt$ line$ i++){ if($ col & gt;1)$ likeType。=“& lt;dl & gt\ r \ n“;for($ j = 0;$ j & lt$ col$ j++){ if($ col & gt;1)$ likeType。=“& lt;dd & gt\ r \ n“;if($ row = $ dsql-& gt;GetArray()){ if($ type = =‘self‘& amp;& amp$ row【& amp;#39;id & amp#39;】= = $ typeid)//处理同级列中当前列的样式{ if($ current style!=“““{ $ linkOkstr = $ current style;$ row【& amp;#39;typelink & amp#39;】= GetOneTypeUrlA($ row);$ link okstr = str _ replace(“~ type link ~“,$ row【& amp;#39;typelink & amp#39;】,$ linkOkstr);$ linkOkstr = str _ replace(“~ typename ~“,$ row【& amp;#39;键入名称和名称。#39;】,$ linkOkstr);$likeType。= $ linkOkstr} } else { $ row【& amp;#39;typelink & amp#39;】= $ row【& amp;#39;typeurl & amp#39;】= GetOneTypeUrlA($ row);if(is _ array($ DTP 2-& gt;CTags){ foreach($ DTP 2-& gt;CTags as $ tagid = & gt$ ctag){ if(isset(row【$ ctag-& gt;GetName()】){ $ DTP 2-& gt;assign($ tagid,$ row【$ ctag-& gt;GetName()】);}埃尔塞夫(preg_match('/^sonchannel[0-9]*$/',$ctag->GetName())){ $ DTP 2-& gt;assign($ tagid,lib _ channel _ son($ ctag,$ row【& amp;#39;id & amp#39;】,$ dsql 2);} } } $likeType。= $ DTP 2-& gt;GetResult();} } if($ col & gt;1)$ likeType。=“& lt;/DD & gt;\ r \ n“;$ GLOBALS【& amp;#39;自动索引& amp#39;]++;}//循环Col if($ Col & gt;1){ $ I+= $ col–1;$likeType。=“& lt;/dl & gt;\ r \ n“;} }//循环执行$ I reset($ dsql 2);$ dsql-& gt;free result();返回$ likeType} function lib _ channel _ son($ ctag,$typeid = 0,$ dsql 2){ $ attlist =“row | 100,col|1,current style |“;FillAttsDefault($ ctag-& gt;属性-& gt;Items,$ attlist);提取($ ctag-》;属性-& gt;Items,EXTR _ SKIP);$ innertext = $ ctag-& gt;GetInnerText();$ dsql3 = clone $ dsql2$ likeType =“;//if($ _ sys _ globals【& amp;#39;typeid & amp#39;】& gt0)$ typeid = $ _ sys _ globals【& amp;#39;typeid & amp#39;];if($ typeid = = 0){ return“;} $ SQL =“Select id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath,description From ying_arctype其中Reid =‘$ typeid‘和ishidden & lt& gt1 order by sortrank asc limit 0,$ row“;//和id & lt& gt$ typeid‘$ DTP 2 = new DedeTagParse();$ DTP 2-& gt;set namespace(“field“,“【& quot,& quot]");$ DTP 2-& gt;load source($ innertext);$ dsql 2-& gt;SetQuery($ SQL);$ dsql 2-& gt;execute();$ line = $ rowfor($ I = 0;$ i & lt$ line$ i++){ if($ col & gt;1)$ likeType。=“& lt;dl & gt\ r \ n“;for($ j = 0;$ j & lt$ col$ j++){ if($ col & gt;1)$ likeType。=“& lt;dd & gt\ r \ n“;if($ row = $ dsql 2-& gt;GetArray()){ $ row【& amp;#39;typelink & amp#39;】= $ row【& amp;#39;typeurl & amp#39;】= GetOneTypeUrlA($ row);if(is _ array($ DTP 2-& gt;CTags){ foreach($ DTP 2-& gt;CTags as $ tagid = & gt$ ctag){ if(isset(row【$ ctag-& gt;GetName()】){ $ DTP 2-& gt;assign($ tagid,$ row【$ ctag-& gt;GetName()】);}埃尔塞夫(preg_match('/^sonchannel[0-9]*$/',$ctag->GetName())){ $ DTP 2-& gt;assign($ tagid,lib _ channel _ son($ ctag,$ row【& amp;#39;id & amp#39;】,$ dsql 3);} } } $likeType。= $ DTP 2-& gt;GetResult();} if($ col & gt;1)$ likeType。=“& lt;/DD & gt;\ r \ n“;}//循环Col if($ Col & gt;1){ $ I+= $ col–1;$likeType。=“& lt;/dl & gt;\ r \ n“;} }//循环执行$ I reset($ dsql 3);$ dsql 2-& gt;free result();返回$ likeType} ?& gt使用【field:son channel 0】【/field:son channel 0】在模板中调用,该模板用于获取子列(使用【sonchannel+ number】作为标签名称是为了防止标签在嵌套时被正确解析),这样做的作用是为了在您的列有许多具有无限评级的子列时方便您获取子列。例如:

代码如下:

& ltul id = & quot左导航& quot& gt{ dede:channel type = & amp;#39;儿子& amp#39;typeid = & amp#39;16 & amp#39;} & lt李& gt& lta href = & quot【field:type link/】“& gt;【field:typename/】& lt;/a & gt;& ltul & gt【field:sonchannel 0】& lt;李& gt& lta href = & quot【field:type link/】“& gt;【field:typename/】& lt;/a & gt;& ltul & gt【field:sonchannel 1】& lt;李& gt& lta href = & quot【field:type link/】“& gt;【field:typename/】& lt;/a & gt;& ltul & gt【field:sonchannel 2】& lt;李& gt& lta href = & quot【field:type link/】“& gt;【field:typename/】& lt;/a & gt;& ltul & gt【field:sonchannel 3】& lt;李& gt& lta href = & quot【field:type link/】“& gt;【field:typename/】& lt;/a & gt;& lt/李& gt【/field:sonchannel 3】& lt;/ul & gt;& lt/李& gt【/field:sonchannel 2】& lt;/ul & gt;& lt/李& gt【/field:sonchannel 1】& lt;/ul & gt;& lt/李& gt【/field:sonchannel 0】& lt;/ul & gt;& lt/李& gt{/dede:channel } & lt;/ul & gt;只需将上面的类型id中的数字更改为您的大类别ID,因为在DEDE的官方论坛中没有找到它,所以我将把它贴在这里,希望它会方便有用的人。

注意:请在修改文件前进行备份。上述代码中的一些引号可能会自动转换为全角。请将其修改为半角,或者您可以向韩笑索要修改后的文件。

这几篇文章你可能也喜欢:

本文由主机参考刊发,转载请注明:如何在DEDECMS中获得无限列子类别 https://zhujicankao.com/113960.html

【腾讯云】领8888元采购礼包,抢爆款云服务器 每月 9元起,个人开发者加享折上折!
打赏
转载请注明原文链接:主机参考 » 如何在DEDECMS中获得无限列子类别
主机参考仅做资料收集,不对商家任何信息及交易做信用担保,购买前请注意风险,有交易纠纷请自行解决!请查阅:特别声明

评论 抢沙发

评论前必须登录!