本文介绍了织梦dedecms想给导航外部链接加上nofollow怎么弄,所谓外部链接就是跳到第三方平台的链接,比如说你做公司网站的,可能在天猫或淘宝有个店铺,为了宣传你的店铺,想把这个店铺的链接放到导航里面,这就是外部链接,加nofollow的意义是防止权重流失。
下面92建站就和大家聊聊织梦想给导航外部链接加上nofollow怎么弄。
打开 /include/taglib/channel.lib.php,找到
if($needRel)
{
$row['sonids'] = GetSonIds($row['id'], 0, false);
if($row['sonids']=='') $row['rel'] = '';
else $row['rel'] = "id']}'";
}
下面增加
$row['target'] = ($row['ispart']==2) ? "target = '_blank'" : "target = '_self'"; //新窗口打开
$row['nofollow'] = ($row['ispart']==2) ? "rel = 'nofollow'" : "rel = 'follow'"; //nofollow属性
需要currentstyle支持这两个属性,继续往下找到
$linkOkstr = str_replace("~typename~",$row['typename'],$linkOkstr);
下面增加
$linkOkstr = str_replace("~target~",$row['target'],$linkOkstr);
$linkOkstr = str_replace("~nofollow~",$row['nofollow'],$linkOkstr);
在导航标签里面增加新标签[field:target/]、[field:nofollow/]即可,这两个标签根据实际情况使用。
{dede:channel type='self' currentstyle="
<li class='thisclass'><a href='~typelink~' ~target~ ~nofollow~>~typename~</a></li>"}
<li><a href='[field:typeurl/]' [field:target/] [field:nofollow/]>[field:typename/]</a></li>
{/dede:channel}
这样整个二次开发就结束了,对着教程使用吧。