织梦dedecms内页(内容页)调用该栏目的父级(顶级栏目)名称和链接的方法
织梦dedecms内页(内容页)调用该栏目的父级(顶级栏目)名称和链接的方法
内页下级栏目获得顶级栏目名称 {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} 内页下级栏目获得顶级栏目链接 {dede:type} [field:id runphp=yes] $tsql = new DedeSql(false); $typelink2 = ''; $tsql->SetQuery("Select i.typedir,i.typename From dede_arctype t left join dede_arctype i on i.id=t.reid where t.id='@me'"); $tsql->Execute('t'); while($row = $tsql->GetArray('t',MYSQL_ASSOC)) { $typelink2 .= ''.$row['typename'].''; } @me=$typelink2; [/field:id] {/dede:type}
内页下级栏目获得顶级栏目名称 {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} 内页下级栏目获得顶级栏目链接 {dede:type} [field:id runphp=yes] $tsql = new DedeSql(false); $typelink2 = ''; $tsql->SetQuery("Select i.typedir,i.typename From dede_arctype t left join dede_arctype i on i.id=t.reid where t.id='@me'"); $tsql->Execute('t'); while($row = $tsql->GetArray('t',MYSQL_ASSOC)) { $typelink2 .= ''.$row['typename'].''; } @me=$typelink2; [/field:id] {/dede:type}