|
调用三级四级无限级栏目效果图
适用于前端简单样式用户,在 include/extend.func.php最后面加上:
/**
* 取出所有分类
* @param int $channel 频道ID
* @return string www.dedeyuan.com
* 调用{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 ishidden1 order by sortrank asc limit 0] $line ");
$dsql->Execute($channel);
if($dsql->GetTotalRow($channel)>0)
{
$result .= "
";
while($row = $dsql->GetArray($channel))
{
$id = $row['id',;
$typename = $row['typename',;
$typelink = GetOneTypeUrlA($row);
$result .= " [*,
";
$result .= " [url={$typelink},{$typename}[/url]
";
getalltype($id,$line);
$result .= "
";
}
$result .= "
";
}
return $result;
}
前台模板调用标签
{dede:global.getalltype function='getalltype()'/}
第二种标签嵌套法
适用于只调用出一级、二级、三级、四级的用户,直接在模板里写
{dede:channelartlist row=7 typeid=top}
[*,
[url=,{dede:field name='typename'/}[/url]
{dede:channel type=son noself=yes}
[*,
[url=,[field:typename/,[/url]
[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 ishidden1 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;
}
@me = $result;
[/field:id,
{/dede:channel}
{/dede:channelartlist}
上面的是输出到三级栏目,如果需要四级栏目可以这样写
[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 ishidden1 order by sortrank asc limit 0]10";
$dsql->SetQuery($sql);
$dsql->Execute('t');
$result = '';
while($row = $dsql->GetArray('t'))
{
$row['typeurl', = GetOneTypeUrlA($row);
$result .= "[url={$row[typeurl]},{$row[typename,}[/url]";
//四级
$nsql = "Select id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl]sitepath
FROM `dede_arctype` WHERE reid=$row[id, And ishidden1 order by sortrank asc limit 0]10";
$dsql->SetQuery($nsql);
$dsql->Execute('n');
while($nrow = $dsql->GetArray('n'))
{
$nrow['typeurl', = GetOneTypeUrlA($nrow);
$result .= "[url={$nrow[typeurl]},{$nrow[typename,}[/url]";
}
}
@me = $result;
[/field:id, |
|