两只小兔 發表於 2024-8-9 00:00:00

dedecms织梦自定义文件名之用拼音或英文标题的方法

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