dedecms织梦自定义文件名之用拼音或英文标题的方法
<p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";">让DedeCMS文章标题页显示路径为“标题拼音.html”,例如:文章标题为:我是一个兵,文章路径显示:woshiyigebing.html</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";">
方法:</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";">
后台-->网站栏目管理,修改栏目的高级选项,文章命名规则:{typedir}/{Y}{M}{D}/{aid}.html</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";">
修改为:{typedir}/{pinyin}.html</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";">
{Y}{M}{D}没什么用,所以去掉了。</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";">
更新一下文档,woshiyigebing_1.html 出来了,但是后面还多了个_,怎么去掉这个呢?</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";">
修改文件:include/inc_channel_unit_function.php</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";">
在大约50多行的地方找到$articleRule = str_replace("{pinyin}",GetPinyin($title)."_".$aid,$articleRule); 把."_".$aid去掉,就可以了!</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";">
如果文章标题是英文的,会在单词之间加"_",但是单词中间加_对SEO来说没什么意义,那我们把它改成“-”。方法如下:</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";">
修改文件: include/inc/inc_fun_funAdmin.php</p><div class="jb51code" style="margin: 0px; padding: 0px; outline: none; line-height: 25.2px; font-size: 14px; width: 660px; overflow: hidden; clear: both; font-family: tahoma, arial, "Microsoft YaHei";"><pre class="brush:php;toolbar:false;">for($i=0;$i0x80)
{
$c = $str[$i].$str[$i+1];
$i++;
if(isset($pinyins[$c])){
if($ishead==0) $restr .= $pinyins[$c];
else $restr .= $pinyins[$c];
}else $restr .= "_";
}else if( eregi("",$str[$i]) ){ $restr .= $str[$i]; }
else{ $restr .= "_"; }
}</pre></div><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";">
如果我们想让拼音也像英文那样中间加“-”,方法是:</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";">
修改文件:include\inc\inc_fun_funAdmin.php</p><div class="jb51code" style="margin: 0px; padding: 0px; outline: none; line-height: 25.2px; font-size: 14px; width: 660px; overflow: hidden; clear: both; font-family: tahoma, arial, "Microsoft YaHei";"><pre class="brush:php;toolbar:false;"> for($i=0;$i0x80)
{
$c = $str[$i].$str[$i+1];
$i++;
if(isset($pinyins[$c])){
if($ishead==0) $restr .= $pinyins[$c]."-";
else $restr .= $pinyins[$c];
}else $restr .= "_";
}else if( eregi("",$str[$i]) ){ $restr .= $str[$i]; }
else{ $restr .= "_"; }
}
if($isclose==0) unset($pinyins);
if(substr($restr,-1)=="-") $restr = substr($restr,0,strlen($restr)-1);
return $restr;
}</pre></div><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";">
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。</p>
頁:
[1]