第一种自定义函数递归法
适用于前端简单样式用户,在 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 织梦模板下载
* 调用{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;
}
前台模板调用标签
{dede:global.getalltype function='getalltype()'/}
第二种标签嵌套法
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}
<!-- 顶级 -->
<li>