/**
* 获取一个类目的顶级栏目
* @param string $tid 栏目ID
* @return string
*/
if ( ! function_exists('gettoptype'))
{
function gettoptype($tid,$action)
{
global $dsql,$cfg_Cs;
if(!is_array($cfg_Cs))
{
require_once(DEDEDATA."/cache/inc_catalog_base.inc");
}
if(!isset($cfg_Cs[$tid][0]) || $cfg_Cs[$tid][0]==0)
{
$topid = $tid;
}
else
{
$topid = GetTopid($cfg_Cs[$tid][0]);
}
$row = $dsql->GetOne("SELECT * FROM `arctype` WHERE id=$topid");
$toptypename = $row['typename'];
$toptypeurl = $topid;
if($action=='id') return $topid;
if($action=='name') return $toptypename;
if($action=='link') return GetOneTypeUrlA($row);
}
}
|