dedemcs文章和列表页均使用拼音方法


一、dedecms修改默认文章命名规则 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>     二、dedecms修改默认列表命名规则 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 以上设置只对本次程序运行有效。