国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > CMS > 織夢DEDE > 正文

DEDE織夢文章和列表頁均使用拼音,使之更適合于SEO的解決方案

2024-07-12 08:58:58
字體:
來源:轉載
供稿:網友
一、DEDE  修改默認文章命名規則
1、單獨添加分類默認修改,修改文件:include/common.inc.php。
查找代碼: 
//文檔的默認命名規則
$art_shortname = $cfg_df_ext = '.html';
$cfg_df_namerule = '{typedir}/{Y}/{M}{D}/{aid}'.$cfg_df_ext;
更改為:
$art_shortname = $cfg_df_ext = '.html';
$cfg_df_namerule = '{typedir}/{pinyin}'.$cfg_df_ext;

2、批量添加分類默認修改,修改文件:dede/templets/catalog_add_quick.htm
查找代碼:
<tr>
<td height="26" class='bline'>文章命名規則:</td>
<td class='bline'><input name="namerule" type="text" id="namerule" value="{typedir}/{Y}{M}{D}/{aid}.html" size="40" class="pubinputs" />
<img src="img/help.gif" alt="幫助" width="16" height="16" border="0" style="cursor:pointer" onClick="ShowHide('helpvar2')" /> </td> </tr>
更改為:
<tr>
<td height="26" class='bline'>文章命名規則:</td>
<td class='bline'><input name="namerule" type="text" id="namerule" value="{typedir}/{pinyin}.html" size="40" class="pubinputs" />
<img src="img/help.gif" alt="幫助" width="16" height="16" border="0" style="cursor:pointer" onClick="ShowHide('helpvar2')" /> </td> </tr>

二、DEDE  修改默認列表命名規則
1、單獨添加分類默認修改,修改文件:dede/templets/catalog_add.htm
查找代碼:
<tr>
<td height="26">列表命名規則:</td>
<td>
<input name="namerule2" type="text" id="namerule2" value="{typedir}/list_{tid}_{page}.html"  class="pubinputs"  style="width:250px" /> <img src="img/help.gif" alt="幫助" width="16" height="16" border="0" style="cursor:pointer" onClick="ShowHide('helpvar3')"/>
</td> 
</tr>
更改為:
<tr>
<td height="26">列表命名規則:</td>
<td>
<input name="namerule2" type="text" id="namerule2" value="{typedir}/{typedir}-{page}.html"  class="pubinputs"  style="width:250px" /> <img src="img/help.gif" alt="幫助" width="16" height="16" border="0" style="cursor:pointer" onClick="ShowHide('helpvar3')"/>
</td> 
</tr>

去除后面的文章ID
修改include/helpers/channelunit.helper.php中的:
$articleRule = str_replace('{pinyin}',GetPinyin($title).'_'.$aid,$articleRule);
$articleRule = str_replace('{py}',GetPinyin($title,1).'_'.$aid,$articleRule);
兩行為:
$articleRule = str_replace('{pinyin}',GetPinyin($title),$articleRule);
$articleRule = str_replace('{py}',GetPinyin($title,1),$articleRule);
保存OK

2、批量添加分類默認修改,修改文件:dede/templets/catalog_add_quick.htm
查找代碼: 
<tr>
<td height="26">列表命名規則:</td>
<td><input name="namerule2" type="text" id="namerule2" value="{typedir}/list_{tid}_{page}.html" size="40" class="pubinputs" />
 <img src="img/help.gif" alt="幫助" width="16" height="16" border="0" style="cursor:pointer" onClick="ShowHide('helpvar3')" />
</td>
</tr>
更改為:
<tr>
<td height="26">列表命名規則:</td>
<td><input name="namerule2" type="text" id="namerule2" value="{typedir}/{typedir}-{page}.html" size="40" class="pubinputs" />
 <img src="img/help.gif" alt="幫助" width="16" height="16" border="0" style="cursor:pointer" onClick="ShowHide('helpvar3')" />
</td>
</tr>

3、對于列表命名規則更改之后,子級欄目生成列表文件的時候會出錯,不能創建文件,原因是{typedir}-{page}.html文件名里面重復了{typedir}的父目錄
生成文件的路徑就像 /parent/parent/sub-1.html,名字里面包含了一個“/”所以會出錯,解決辦法是:


打開include/arc.listview.class.php,找到323行代碼:
$makeFile = str_replace("{page}", $this->PageNo, $makeFile);這里的$makeFile就是要生成的文件路徑,處理一下就可以了。
在此行代碼下面添加以下代碼:
/*****自己添加的處理以{typedir}為列表命名規則時,去除生成列表文件名中重復了父目錄的程序****/
if(strpos($makeFile,"//")>0){
 $tmpArr = explode("//",$makeFile);
 $makeFile = $tmpArr[0];
 if(strpos($tmpArr[1],"/")>0){
   $tmpArr1 = explode("/",$tmpArr[1]);
   $makeFile .= "/".$tmpArr1[1];
 }else{
   $makeFile .= "/".$tmpArr[1];
 }
}
/*****處理程序結束*****/


然后找到下面的:$list_1 = $this->GetTruePath().$onlyrule;代碼,這個是要復制第一個列表文件為index的路徑
同樣在下面添加代碼:
/*****自己添加的處理以{typedir}為列表命名規則時,去除生成列表文件名中重復了父目錄的程序****/
if(strpos($list_1,"//")>0){
 $tmpArr = explode("//",$list_1);
 $list_1 = $tmpArr[0];
 if(strpos($tmpArr[1],"/")>0){
   $tmpArr1 = explode("/",$tmpArr[1]);
   $list_1 .= "/".$tmpArr1[1];
 }else{
   $list_1 .= "/".$tmpArr[1];
 }
}
/*****處理程序結束*****/


保存就OK。

列表頁和文章頁都采用拼音的URL形式了,

不是原來的list_1.html的形式,更有利于SEO優化搜索

主要是說明這個修改和處理的位置,可以根據自己需求進一步更改完善。


有時dede后臺生成欄目列表頁太多了時,沒有生成完就退出循環,顯示一片空白了。
原因是有可能代碼執行時間不夠,也有可能會是代碼執行分配的內存不足。
修改方法是在代碼開始執行前設置執行最大時間和內存:
set_time_limit(0); //設置代碼執行最大時間為不限制
ini_set("memory_limit", 1048576000);  //設置內存限制為1G
以上設置只對本次程序運行有效。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 涡阳县| 高雄县| 勐海县| 普定县| 彭山县| 广平县| 吉林市| 新巴尔虎左旗| 洱源县| 中西区| 诸暨市| 门源| 平阳县| 哈巴河县| 乡宁县| 黄平县| 广东省| 廊坊市| 长顺县| 准格尔旗| 石河子市| 浦城县| 临夏县| 秦皇岛市| 全州县| 四川省| 南京市| 浦城县| 黑龙江省| 阿拉善盟| 正蓝旗| 象州县| 慈利县| 虹口区| 盈江县| 沁水县| 南陵县| 揭西县| 铜梁县| 建始县| 浦东新区|