现在基于web2.0的下拉菜单 多是以
<ul>
<li>
<a>一级菜单</a>
<ul>
<li>
<a>二级级菜单</a>
</li>
</ul>
</li>
</ul>
这样的格式来实现的。但是dede的{dede:channel}标签是无法实现这个效果的,或者只有添加typeid这个参数来手工实现下拉菜单,这样的效果耗时耗力。
于是觉得只有改底层模板来实现了,高了一个小时以后增加了标签
{dede:channeli row='''' type=''top''}
{typelink:root}<li><a href="[field:typelink/]">[field:typename/]</a><ul>[field:child/]</ul></li>{/typelink:root}
{typelink:children}<li><a href="[field:typelink/]">[field:typename/]</a></li>{/typelink:children}
{/dede:channeli}
其实就是一个嵌套的标签
{typelink:root}<li><a href="[field:typelink/]">[field:typename/]</a><ul>[field:child/]</ul></li>{/typelink:root}
是父菜单的innertext
{typelink:children}<li><a href="[field:typelink/]">[field:typename/]</a></li>{/typelink:children}
是子菜单的innertext
由于系统的消耗,目前就支持两级 ,其实已经够用了!
这里相信大家已经看懂了思路了,下面就是修改办法:
include/inc_typelink.php
增加函数:
function GetChanneli($typeid=0,$reID=0,$row=8,$typetype=''sun'',$innertext='''',$myinnertext='''')
{
if($typeid==0) $typeid = $this->TypeID;
if($row=="") $row = 8;
if($reID=="") $reID = 0;
if($col=="") $col = 1;
if($typetype=="") $typetype="sun";
if($innertext=="") $innertext = GetSysTemplets("channel_list.htm");
if($reID==0 && $typeid>0){
$dbrow = $this->dsql->GetOne("Select reID From #@__arctype where ID=''$typeid'' ");
if(is_array($dbrow)) $reID = $dbrow[''reID''];
}
$likeType = "";
if($typetype=="top"){
$sql = "Select ID,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl
From #@__arctype where reID=0 And ishidden<>1 order by sortrank asc limit 0,$row";
}
else if($typetype=="sun"||$typetype=="son"){
$sql = "Select ID,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl
From #@__arctype where reID=''$typeid'' And ishidden<>1 order by sortrank asc limit 0,$row";
}
else if($typetype=="self"){
$sql = "Select ID,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl
From #@__arctype where reID=''$reID'' And ishidden<>1 order by sortrank asc limit 0,$row";
}
//扩展二级菜单
//主菜单的innertext
$root="";
//带有子菜单的innertext
$rootc="";
//子菜单的innertext
$children="";
$dtp3 = new DedeTagParse();
$dtp3->SetNameSpace("typelink","{","}");
$dtp3->LoadSource($innertext);
if(is_array($dtp3->CTags))
{
foreach($dtp3->CTags as $tagid=>$ctag )
{
$tagname=$ctag->GetName();
if($tagname=="root")
{
$root=$ctag->GetInnerText();
}
else if($tagname=="rootc")
{
$rootc=$ctag->GetInnerText()