首页 > 代码库 > dedecms织梦自定义函数递归拿所有分类(无限分类)

dedecms织梦自定义函数递归拿所有分类(无限分类)

技术分享

 

 

/**
* 取出所有分类
* @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 `blog_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=http://www.mamicode.com/‘{$typelink}‘ target=‘_blank‘>{$typename}/r/n";
			getalltype($id,$line);
			$result .= "	</li>\r\n";
		}
        $result .= "</ul>\r\n";
	}
	return $result;
}

 

dedecms织梦自定义函数递归拿所有分类(无限分类)