织梦dede子栏目获取父栏目名称及链接

织梦一般情况下当前栏目获取父栏目(或者叫顶级栏目)都是通过ID来获取的,下面是织梦dedeCMS子栏目获取父栏目名称及链接方法,通过当前栏目反推获得父级栏目名称和链接地址:

{dede:field name=’typeid’ runphp=’yes’}
global $dsql;
/*获取当前栏目id*/
$typeid = @me;
$query = “SELECT reid FROM dede_arctype where id = $typeid”;
$rs = $dsql->GetOne($query);
$reid = $rs[‘reid’];//获取到栏目的上级栏目
/*获取上级栏目id*/
$query2 = “SELECT * FROM dede_arctype where id = $reid”;
$row = $dsql->GetOne($query2);
/*输出上级栏目信息*/
$typename = $row[‘typename’];
$link = GetTypeUrl($row[‘typeid’],MfTypedir($row[‘typedir’]),$row[‘isdefault’],$row[‘defaultname’],$row[‘ispart’],$row[‘namerule2’],$row[‘moresite’],$row[‘siteurl’],$row[‘sitepath’]);
@me = “<a href='{$link}’>$typename</a>”;
{/dede:field}

暂无评论

发表评论