調(diào)用三級(jí)四級(jí)無(wú)限級(jí)欄目效果圖
第一種自定義函數(shù)遞歸法
適用于前端簡(jiǎn)單樣式用戶,在 include/extend.func.php 最下面添加
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | /** * 取出所有分類 * @param int $channel 頻道ID * @return string www.dedecms51.com下載 * 調(diào)用{dede:global.getalltype function='getalltype()'/} */ function getalltype($channel=0,$line=10) { $line = empty($line) ? 10 : $line; global $dsql,$result; $dsql->SetQuery("SELECT id,typename,typenamedir,typelitpic,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath FROM `dede_arctype` WHERE reid='$channel' And ishidden<>1 order by sortrank asc limit 0, $line "); $dsql->Execute($channel); if($dsql->GetTotalRow($channel)>0) { $result .= "<ul>\r\n"; while($row = $dsql->GetArray($channel)) { $id = $row['id']; $typename = $row['typename']; $typelink = GetOneTypeUrlA($row); $result .= " <li>\r\n"; $result .= " <a href='{$typelink}' target='_blank'>{$typename}</a>\r\n"; getalltype($id,$line); $result .= " </li>\r\n"; } $result .= "</ul>\r\n"; } return $result; } |
前臺(tái)模板調(diào)用標(biāo)簽
{dede:global.getalltype function='getalltype()'/}
第二種標(biāo)簽嵌套法
適用于只調(diào)用出一級(jí)、二級(jí)、三級(jí)、四級(jí)的用戶,直接在模板里寫
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | <ul> {dede:channelartlist row=7 typeid=top} <!-- 頂級(jí) --> <li> <a href="{dede:field.typeurl/}" >{dede:field name='typename'/}</a> <ul> {dede:channel type=son noself=yes} <!-- 二級(jí) --> <li> <a href="[field:typeurl/]" title="[field:typename/]">[field:typename/]</a> <ul> <!-- 三級(jí) --> [field:id runphp=yes] global $dsql; $sql = "Select id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath FROM `dede_arctype` WHERE reid=@me And ishidden<>1 order by sortrank asc limit 0,10"; $dsql->SetQuery($sql); $dsql->Execute('t'); $result = ''; while($row = $dsql->GetArray('t')) { $typename = $row['typename']; $typeurl = GetOneTypeUrlA($row); $result .= <<< TPL <li><a href="{$typeurl}">{$typename}</a></li> TPL; } @me = $result; [/field:id] </ul> </li> {/dede:channel} </ul> </li> {/dede:channelartlist} </ul> |
上面的是輸出到三級(jí)欄目,如果需要四級(jí)欄目可以這樣寫
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | <!-- 三級(jí)/四級(jí) --> [field:id runphp=yes] global $dsql; $sql = "Select id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath FROM `dede_arctype` WHERE reid=@me And ishidden<>1 order by sortrank asc limit 0,10"; $dsql->SetQuery($sql); $dsql->Execute('t'); $result = ''; while($row = $dsql->GetArray('t')) { $row['typeurl'] = GetOneTypeUrlA($row); $result .= "<a href='{$row[typeurl]}'>{$row[typename]}</a>"; //四級(jí) $nsql = "Select id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath FROM `dede_arctype` WHERE reid=$row[id] And ishidden<>1 order by sortrank asc limit 0,10"; $dsql->SetQuery($nsql); $dsql->Execute('n'); while($nrow = $dsql->GetArray('n')) { $nrow['typeurl'] = GetOneTypeUrlA($nrow); $result .= "<a href='{$nrow[typeurl]}'>{$nrow[typename]}</a>"; } } @me = $result; [/field:id] |
版權(quán)聲明: 本站資源均來(lái)自互聯(lián)網(wǎng)或會(huì)員發(fā)布,如果侵犯了您的權(quán)益請(qǐng)與我們聯(lián)系,我們將在24小時(shí)內(nèi)刪除!謝謝!
轉(zhuǎn)載請(qǐng)注明: dedecms織夢(mèng)調(diào)用三級(jí)四級(jí)無(wú)限級(jí)欄目教程