dedecms织梦给栏目增加链接属性rel、nofollow和新窗口target

大家应该都知道rel='nofllow'的作用,它是告诉搜索引擎,不要将该链接计入权重。
因此多数情况下,我们可以将一些不想传递权重的链接进行nofllow处理;
例如一些非本站的链接,不想传递权重,但是又需要加在页面中的,
像 外部链接、统计代码、备案号链接、供用户查询的链接等等。
为了方便管理,直接在织梦后台栏目里自由把控每个栏目对应的链接属性,
我们来给织梦栏目增加链接属性rel="nofllow" rel="external" rel="external nofollow"和新窗口target="_blank"
rel="nofllow" (告诉搜索引擎该链接不计入权重)
rel="external" (告诉搜索引擎该链接不是本站链接)
rel="external nofollow" (告诉搜索引擎该链接不是本站链接也不计入权重)


实现教程
1、后台-系统-SQL工具,执行

ALTER TABLE `dede_arctype` ADD `nofollow` CHAR( 60 ) NOT NULL DEFAULT '';
ALTER TABLE `dede_arctype` ADD `target` CHAR( 60 ) NOT NULL DEFAULT '';

2、打开 /dede/catalog_add.php 找到,大概在 239 行左右

UpDateCatCache();

在它的 上面 加入

$id = $dsql->GetLastID();
$upquery = "UPDATE `dede_arctype` SET `nofollow`='$nofollow',`target`='$target' WHERE id='$id' ";
$dsql->ExecuteNoneQuery($upquery);

3、打开 /dede/catalog_edit.php 找到,大概在 106 行左右

UpDateCatCache();

在它的 上面 加入

$upquery = "UPDATE `dede_arctype` SET `nofollow`='$nofollow',`target`='$target' WHERE id='$id' ";
$dsql->ExecuteNoneQuery($upquery);

4、打开 /dede/templets/catalog_add.htm 找到

栏目属性

在它上面一行的<tr>上面加入

<tr> 
<td width="150" class='bline' height="26" style="padding-left:10px;">链接属性rel:</td>
<td class='bline'>
<select name="nofollow" id="nofollow" style="width:140px;">
<option value=''>请选择属性</option>
<option value='rel="external"'>external</option>
<option value='rel="nofollow"'>nofollow</option>
<option value='rel="external nofollow"'>external nofollow</option>
</select>
<input style="vertical-align:middle; margin-top:-2px; margin-bottom:1px;" type="checkbox" name="target" value='target="_blank"' class="np">
新窗口打开
</td>
</tr>

如图


5、打开 /dede/templets/catalog_edit.htm 找到
栏目属性
在它上面一行的<tr>上面加入

<tr> 
<td width="150" class='bline' height="26" style="padding-left:10px;">链接属性rel:</td>
<td class='bline'>
<select name="nofollow" id="nofollow" style="width:140px;">
<option value=''<?php if($myrow['nofollow']=='') echo " selected";?>>请选择属性</option>
<option value='rel="external"'<?php if($myrow['nofollow']=='rel="external"') echo " selected";?>>external</option>
<option value='rel="nofollow"'<?php if($myrow['nofollow']=='rel="nofollow"') echo " selected";?>>nofollow</option>
<option value='rel="external nofollow"'<?php if($myrow['nofollow']=='rel="external nofollow"') echo " selected";?>>external nofollow</option>
</select>
<input style="vertical-align:middle; margin-top:-2px; margin-bottom:1px;" type="checkbox" name="target" value='target="_blank"' class="np"<?php if($myrow['target']=='target="_blank"') echo " checked='1' ";?>>
新窗口打开
</td>
</tr>

如图


6、打开 /include/taglib/channel.lib.php 找到,80、86、92、111行的

id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath

这4处都改成

*

如图


7、打开 /include/taglib/channelartlist.lib.php 找到,大概在 78 行

id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath 

改成

*

如图


8、打开 /include/taglib/type.lib.php 找到,大概在 42 行

id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath 

改成

*

如图


栏目调用标签里的标签写法
dede:channelartlist标签写法

<ul>
    {dede:channelartlist row=7 typeid=top}
    <li><a href="{dede:field.typeurl/}" {dede:field.nofollow/} {dede:field.target/}>{dede:field.typename/}</a></li>
    {/dede:channelartlist}
</ul>

dede:channel标签写法

{dede:channel type=top row=7}
<li><a href="[field:typelink/]" [field:nofollow/] [field:target/]>[field:typename/]</a></li>
{/dede:channel}

dede:type标签写法

{dede:type typeid=1}
<li><a href="[field:typeurl/]" [field:nofollow/] [field:target/]>[field:typename/]</a></li>
{/dede:type}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值