Dedecms 获得顶级栏目名称的SQL语句
适用于 DEDE5.5
{dede:field.typeid runphp='yes'}$ID = @me; $sql = "SELECT `reid` FROM `dede_arctype` WHERE id=$ID";$query = mysql_query($sql);$row=mysql_fetch_array($query); $relID = "$row[reid]";$sql2 = "SELECT `typename` FROM `dede_arctype` WHERE id=$relID";$query2 = mysql_query($sql2);$row2=mysql_fetch_array($query2); @me = $row2[typename];{/dede:field.typeid}
上面那个不是很完善,当栏目本来就是顶级栏目时就得不到了,用这个吧
{dede:field.typeid runphp='yes'}$ID = @me; $sql = "SELECT * FROM `dede_arctype` WHERE id=$ID";$query = mysql_query($sql);$row=mysql_fetch_array($query); $relID = "$row[reid]"; if($relID == 0) {@me = $row[typename];}else{$sql = "SELECT `typename` FROM `dede_arctype` WHERE id=$relID";$query = mysql_query($sql);$row=mysql_fetch_array($query); @me = $row[typename];}{/dede:field.typeid}