DedeCMS调用当前文档所在栏目链接与名称

dede内容页调用标签

        在内容页模板时,我们经常会调用本文链接来做版权声明。DedeCMS没有相应的调用代码,用 {dede:field.typename/} 来表示当前文档的栏目名称,本贴介绍用 {dede:field.typeurl/} 形式来调用栏目链接,该方法同时支持DedeV5.5/5.6/5.7,不区分程序编码。

 

解决办法

第一步:打开 /include/arc.archives.class.php 文件,找到约241行如下代码

//设置全局环境变量
$this->Fields['typename'] = $this->TypeLink->TypeInfos['typename'];

 

在其下一行加入如下代码:

 

//设置全局环境变量
$this->Fields['typelink'] = $this->TypeLink->GetOneTypeLink($this->TypeLink->TypeInfos);
$this->Fields['typeurl'] = $this->TypeLink->GetOneTypeUrl($this->TypeLink->TypeInfos);

 

第二步:在你的内容页模板适当位置加入调用代码

{dede:field.typelink/} 带链接的栏目名称,显示:<a href="栏目链接地址">栏目名称</a>

{dede:field.typeurl/} 仅栏目链接,显示: /news