How to get any column N-level list Link Tree menu by DedeCms
How does DedeCms get any column N-level list link tree menu? This problem may be often seen in our daily study or work. I hope you can gain a lot from this question. The following is the reference content that the editor brings to you, let's take a look at it!
How does DedeCms get any column N-level list link tree menu?
DedeCms access to any column N-level list link tree menu, editor tips, the following modification method, applicable to the default table prefix of DedeCMS, if you modify it during installation, please pay attention to the modification.
Recommended study: dream weaving cms
Add the following code at the bottom of the\ include\ channelunit.func.php file:
/ * Tree column supplement, get level 2, san, level 4 column list / function getProductTree ($typeid) {$linkList = ""; $dsql = new DedeSql (false); $dsql- > SetQuery ("select ID,typedir,typename,isdefault from dede_arctype where reID ='$typeid' order by sortrank"); $dsql- > Execute () While ($row=$dsql- > GetObject ()) {$typelink = GetTypeUrl ($row- > id,MfTypedir ($row- > typedir), $row- > isdefault,$row- > defaultname,$row- > ispart,$row- > namerule2,$row- > moresite,$row- > siteurl,$row- > sitepath); $linkList. = "\ n". $row- > typename. "\ n\ n"; $linkList. = getSonClass ($row- > ID);} $dsql- > Close (); return $linkList;} / / get a link to function getSonClass ($parentid) {$linkList = "" $dsql = new DedeSql (false); $dsql- > SetQuery ("Select ID,typedir,typename,isdefault From dede_arctype where reID='$parentid' order by sortrank"); $dsql- > Execute ($parentid); while ($row=$dsql- > GetObject ($parentid)) {$typelink = GetTypeUrl ($row- > id,MfTypedir ($row- > typedir), $row- > isdefault,$row- > defaultname,$row- > ispart,$row- > namerule2,$row- > moresite,$row- > siteurl,$row- > sitepath); $linkList. = ". $row- > typename." $linkList. = getSonClass2 ($row- > ID);} return $linkList;} function getSonClass2 ($parentid) {$linkList = ""; $dsql = new DedeSql (false); $dsql- > SetQuery ("Select ID,typedir,typename,isdefault From dede_arctype where reID='$parentid' order by sortrank"); $dsql- > Execute ($parentid) While ($row=$dsql- > GetObject ($parentid)) {$typelink = GetTypeUrl ($row- > id,MfTypedir ($row- > typedir), $row- > isdefault,$row- > defaultname,$row- > ispart,$row- > namerule2,$row- > moresite,$row- > siteurl,$row- > sitepath); $linkList. = ". $row- > typename."\ n "; $linkList. = getSonClass3 ($row- > ID);} return $linkList;} function getSonClass3 ($parentid) {$linkList ="; $dsql = new DedeSql (false) $dsql- > SetQuery ("Select ID,typedir,typename,isdefault From dede_arctype where reID='$parentid' order by sortrank"); $dsql- > Execute ($parentid); while ($row=$dsql- > GetObject ($parentid)) {$typelink = GetTypeUrl ($row- > id,MfTypedir ($row- > typedir), $row- > isdefault,$row- > defaultname,$row- > ispart,$row- > namerule2,$row- > moresite,$row- > siteurl,$row- > sitepath); $linkList. = ". $row- > typename."\ n ";} return $linkList;} / * Tree supplement * /
2. Use it in the template
{dede:channel function='getProductTree (2)'} {/ dede:channel}
Just call it. Here 2 in getProductTree (2) is the product display column ID. If yours is something else, please modify it accordingly.
Thank you for reading! After reading the above, do you have a general idea of how DedeCms can get the N-level list link tree menu of any column? I hope the content of the article will be helpful to all of you. If you want to know more about the relevant articles, you are welcome to follow the industry information channel.