织梦dedecms5.7 无限级多级栏目菜单调用方法,织梦
导读:织梦教程织梦教程站长亲测可用 以前在用到5.7无限级栏目列表菜单时下载了网上的资料都未成功,因此我参考网上及dedecms本身的channel.lib.php及cattree.织梦模板网dede模板安装。
站长亲测可用 以前在用到5.7无限级栏目列表菜单时下载了网上的资料都未成功,因此我参考网上及dedecms本身的channel.lib.php及cattree.lib.php制作了调用标签。 1、在include\taglib建立randomartlist.lib.php 内容如下: <?php if(!defined('DEDEINC')) exit('Request Error!'); function lib_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']; } } //调用Typeid if( !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!=''&n织梦的模板bsp;) { $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; } function randomartlistSon($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']&nbs织梦模板网站p;= 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"; } 2、调用方式: <div class="alist"> <ul> {dede:randomartlist topid='12' currentstyle="<li><a href='~typelink~' class='thisclass'>~typename~</a></li>"} <li><a href="{dede:field name='typeurl'/}" title="{dede:field name='typename'/}">{dede:field name='typename'/}</a></li> {/dede:randomartlist} </ul> </div> 3、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{}相关织梦模板网dede模板安装。
声明: 本文由我的SEOUC技术文章主页发布于:2023-07-20 ,文章织梦dedecms5.7 无限级多级栏目菜单调用方法,织梦主要讲述菜单,栏目,织梦网站建设源码以及服务器配置搭建相关技术文章。转载请保留链接: https://www.seouc.com/article/web_31404.html