洞悉互聯網前沿資訊,探尋網站營銷規律
作者:狐靈科技 | 2019-12-24 13:59 |點擊:
網站建設中對不想參與排名的欄目增加rel=nofollow屬性,而DedeCMS并沒這樣的設置,在以前版本有[field:rel/]標簽,等同于dropmenu加上欄目id,并沒有實際作用。實現在{dede:channel}標簽下為某個欄目增加rel=nofollow屬性,跟著重慶SEO吖七修改源文件吧。
Navicat EditPlus
數據庫dede_arttype表 /dede/catalog_add.htm /dede/catalog_add.htm /dede/catalog_edit.php /dede/catalog_edit.html
1.在dede_arttype數據庫表增加isnofollow字段
用Navicat或其他數據庫管理軟件打開dede_arttype表,增加鍵名:isnofollow;類型:smalllint,長度:6;小數點:0;不允許空值。
2.修改/dede/catalog_add.htm
大概在219行
<tr> <td width="150" class='bline' height="26" style="padding-left:10px;">是否隱藏欄目:</td> <td class='bline'> <input type='radio' name='ishidden' value='0' class='np' checked="checked" /> 顯示 <input type='radio' name='ishidden' value='1' class='np' /> 隱藏 </td> </tr>
下面增加
<tr> <td class="bline" style="padding-left:10px;" width="150" height="26">Nofollow設置:</td> <td class="bline"> <input name="isnofollow" value="1" class="np" type="radio" /> 是 <input name="isnofollow" value="0" class="np" type="radio" checked='1' /> 否 </td><!--www.vi586.com--> </tr>
3.修改/dede/catalog_add.php
大概在65行的地方,一定要注意符號
ishidden,
后面增加
isnofollow,
在
'$namerule2','0','0',
后面增加
'0',
另外一處修改,大概在229行
ishidden,
后面增加
isnofollow,
大概在232行
'$ishidden',
后面增加
'$isnofollow',
4.修改/dede/catalog_edit.htm
找到
<tr> <td width="150" class='bline' height="26" style="padding-left:10px;">是否隱藏欄目:</td> <td class='bline'> <input type='radio' name='ishidden' value='0' class='np'<?php if($myrow['ishidden']=="0") echo " checked='1' ";?>/> 顯示 <input type='radio' name='ishidden' value='1' class='np'<?php if($myrow['ishidden']=="1") echo " checked='1' ";?>/> 隱藏 </td> </tr>
下面增加
<tr> <td class="bline" style="padding-left:10px;" width="150" height="26">Nofollow設置:</td> <td class="bline"> <input name="isnofollow" value="1" class="np" type="radio" <?php if($myrow['isnofollow']=="1") echo " checked='1' ";?>> 是 <input name="isnofollow" value="0" class="np" type="radio" <?php if($myrow['isnofollow']=="0") echo " checked='1' ";?>/> 否 </td> </tr>
5.修改/dede/catalog_edit.php
找到如下代碼:
ishidden='$ishidden',
注意一共有兩處,代碼下面增加
isnofollow='$isnofollow',
這樣就可以在欄目修改里看到效果,默認欄目沒有該屬性。
6.前臺模板調用
<div class="nav pl">
<ul>
<li><a href="{dede:global.cfg_basehost/}">{dede:global.cfg_indexname/}</a></li>
{dede:channel typeid='' type='top'}<li><a href="[field:typeurl/]"
[field:isnofollow runphp="yes"]
if(@me==1) @me="rel='nofollow'";else @me="";
[/field:isnofollow]>[field:typename/]</a></li>{/dede:channel}
</ul>
</div>
但是這樣寫是調用不出來的,因為{dede:channel}沒有這個詞,修改方法和增加英文欄目名、欄目縮略圖是一樣的,
打開/include/taglib/channel.lib.php,找到如下代碼,
if($type=='top')
找到
typename
有三處修改,大概在78,86,92行,在typename后面增加下面代碼,注意前面一個逗號。
,isnofollow