dede5.7 動(dòng)態(tài)導(dǎo)航下拉菜單的實(shí)現(xiàn)代碼
來(lái)源:易賢網(wǎng) 閱讀:1281 次 日期:2016-06-29 10:37:25
溫馨提示:易賢網(wǎng)小編為您整理了“dede5.7 動(dòng)態(tài)導(dǎo)航下拉菜單的實(shí)現(xiàn)代碼”,方便廣大網(wǎng)友查閱!

dede5.7 動(dòng)態(tài)導(dǎo)航下拉菜單的實(shí)現(xiàn)代碼,需要的朋友可以參考一下

1.修改 include下面taglib文件夾里的channel.lib.php文件 替換成我的

代碼如下:

<?php

function lib_channel(&$ctag,&$refObj)

{

global $_sys_globals,$envs,$dsql;

$attlist = "typeid|0,reid|0,row|100,col|1,type|son,currentstyle|";

FillAttsDefault($ctag->CAttribute->Items,$attlist);

extract($ctag->CAttribute->Items, EXTR_SKIP);

$innertext = $ctag->GetInnerText();

if(empty($typeid) && $envs['typeid']!=0)

{

$typeid = $envs['typeid'];

$reid = $envs['reid'];

}else{

$reid=0;

if($type==''||$type=='sun') $type="son";

if($innertext=='') $innertext = GetSysTemplets("channel_list.htm");

if($reid==0 && $typeid>0)

{

$dbrow = $dsql->GetOne("Select reid From <a href="mailto:`dede_arctype">`dede_arctype</a>` where id='$typeid' ");

if(is_array($dbrow)) $reid = $dbrow['reid'];

}

$likeType = '';

if($type=='top')

{

$sql = "Select id,typename,typedir,isdefault,ispart,defaultname,namerule2,description

From <a href="mailto:`dede_arctype">`dede_arctype</a>` where reid=0 And ishidden<>1 order by sortrank asc limit 0,$row";

}

else if($type=="son")

{

//if($_sys_globals['typeid']>0) $typeid = $_sys_globals['typeid'];

if($typeid==0) {

return '';

}

$sql = "Select id,typename,typedir,isdefault,ispart,defaultname,namerule2,description

From <a href="mailto:`dede_arctype">`dede_arctype</a>` where reid='$typeid' And ishidden<>1 order by sortrank asc limit 0,$row";

}

else if($type=="self")

{

if($reid==0) {

return '';

}

$sql = "Select id,typename,typedir,isdefault,ispart,defaultname,namerule2,description

From <a href="mailto:`dede_arctype">`dede_arctype</a>` where reid='$reid' And ishidden<>1 order by sortrank asc limit 0,$row";

}

//And id<>'$typeid'

$dtp2 = new DedeTagParse();

$dtp2->SetNameSpace("field","[","]");

$dtp2->LoadSource($innertext);

$dsql2 = clone $dsql;

$dsql->SetQuery($sql);

$dsql->Execute();

$line = $row;

$GLOBALS['autoindex'] = 0;

for($i=0;$i < $line;$i++)

{

if($col>1) $likeType .= "<dl>\r\n";

for($j=0;$j<$col;$j++)

{

if($col>1) $likeType .= "<dd>\r\n";

if($row=$dsql->GetArray())

{

if($type=='self' && $row['id']==$typeid) //處理同級(jí)欄目中,當(dāng)前欄目的樣式

{

if($currentstyle!='')

{

$linkOkstr = $currentstyle;

$row['typelink'] = GetOneTypeUrlA($row);

$linkOkstr = str_replace("~typelink~",$row['typelink'],$linkOkstr);

$linkOkstr = str_replace("~typename~",$row['typename'],$linkOkstr);

$likeType .= $linkOkstr;

}

}else

{

$row['typelink'] = $row['typeurl'] = GetOneTypeUrlA($row);

if(is_array($dtp2->CTags))

{

foreach($dtp2->CTags as $tagid=>$ctag){

if(isset($row[$ctag->GetName()]))

{

$dtp2->Assign($tagid,$row[$ctag->GetName()]);

}

elseif (preg_match('/^sonchannel[0-9]*$/',$ctag->GetName()))

{

$dtp2->Assign($tagid,lib_channel_son($ctag,$row['id'],$dsql2));

}

}

}

$likeType .= $dtp2->GetResult();

}

}

if($col>1) $likeType .= "</dd>\r\n";

$GLOBALS['autoindex']++;

}//Loop Col

if($col>1)

{

$i += $col - 1;

$likeType .= " </dl>\r\n";

}

}//Loop for $i

reset($dsql2);

$dsql->FreeResult();

return $likeType;

}

function lib_channel_son($ctag,$typeid = 0,$dsql2)

{

$attlist = "row|100,col|1,currentstyle|";

FillAttsDefault($ctag->CAttribute->Items,$attlist);

extract($ctag->CAttribute->Items, EXTR_SKIP);

$innertext = $ctag->GetInnerText();

$dsql3 = clone $dsql2;

$likeType = '';

//if($_sys_globals['typeid']>0) $typeid = $_sys_globals['typeid'];

if($typeid==0) {

return '';

}

$sql = "Select id,typename,typedir,isdefault,ispart,defaultname,namerule2,description

From <a href="mailto:`dede_arctype">`dede_arctype</a>` where reid='$typeid' And ishidden<>1 order by sortrank asc limit 0,$row";

//And id<>'$typeid'

$dtp2 = new DedeTagParse();

$dtp2->SetNameSpace("field","[","]");

$dtp2->LoadSource($innertext);

$dsql2->SetQuery($sql);

$dsql2->Execute();

$line = $row;

for($i=0;$i < $line;$i++)

{

if($col>1) $likeType .= "<dl>\r\n";

for($j=0;$j<$col;$j++)

{

if($col>1) $likeType .= "<dd>\r\n";

if($row=$dsql2->GetArray())

{

$row['typelink'] = $row['typeurl'] = GetOneTypeUrlA($row);

if(is_array($dtp2->CTags))

{

foreach($dtp2->CTags as $tagid=>$ctag){

if(isset($row[$ctag->GetName()]))

{

$dtp2->Assign($tagid,$row[$ctag->GetName()]);

}

elseif (preg_match('/^sonchannel[0-9]*$/',$ctag->GetName()))

{

$dtp2->Assign($tagid,lib_channel_son($ctag,$row['id'],$dsql3));

}

}

}

$likeType .= $dtp2->GetResult();

}

if($col>1) $likeType .= "</dd>\r\n";

}//Loop Col

if($col>1)

{

$i += $col - 1;

$likeType .= " </dl>\r\n";

}

}//Loop for $i

reset($dsql3);

$dsql2->FreeResult();

return $likeType;

}

?>

2.調(diào)用

這是我調(diào)用的代碼 

代碼如下:

{dede:channel typeid='1'}

<li>

<a class="" href="[field:typeurl/]" title="">[field:typename/]

<img src="***.gif" /></a>

<div class="sub">

<ul> 

[field:sonchannel0]<li><a href="[field:typeurl/]">[field:typename/]</a></li>[/field:sonchannel0]

</ul>

</div>

</li>

{/dede:channel}

更多信息請(qǐng)查看CMS教程
由于各方面情況的不斷調(diào)整與變化,易賢網(wǎng)提供的所有考試信息和咨詢回復(fù)僅供參考,敬請(qǐng)考生以權(quán)威部門(mén)公布的正式信息和咨詢?yōu)闇?zhǔn)!
相關(guān)閱讀CMS教程

2025國(guó)考·省考課程試聽(tīng)報(bào)名

  • 報(bào)班類型
  • 姓名
  • 手機(jī)號(hào)
  • 驗(yàn)證碼
關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡(jiǎn)要咨詢 | 簡(jiǎn)要咨詢須知 | 加入群交流 | 手機(jī)站點(diǎn) | 投訴建議
工業(yè)和信息化部備案號(hào):滇ICP備2023014141號(hào)-1 云南省教育廳備案號(hào):云教ICP備0901021 滇公網(wǎng)安備53010202001879號(hào) 人力資源服務(wù)許可證:(云)人服證字(2023)第0102001523號(hào)
云南網(wǎng)警備案專用圖標(biāo)
聯(lián)系電話:0871-65099533/13759567129 獲取招聘考試信息及咨詢關(guān)注公眾號(hào):hfpxwx
咨詢QQ:526150442(9:00—18:00)版權(quán)所有:易賢網(wǎng)
云南網(wǎng)警報(bào)警專用圖標(biāo)