Discuz SEO设置 title 不支持空格的解决方法-Discuz教程下载

Discuz SEO设置 title 不支持空格的解决方法

开通本站Svip会员,全站资源免费下
很多使用 Discuz X3.2 的同学都发现这么一个问题:在后台SEO设置-title设定的时候,即使你在连字符两侧输入了空格,在前台也显示不出来,很多同学纠结这个问题,今天终于找到了解决方法,在此分享给大家。

在文件:source\class\helper\helper_seo.php,49行附近,找到如下代码(修改之前请备份好原文件):
  1. public static function strreplace_strip_split($searchs, $replaces, $str) {
  2.     $searchspace = array('((\s*\-\s*)+)', '((\s*\,\s*)+)', '((\s*\|\s*)+)', '((\s*\t\s*)+)', '((\s*_\s*)+)');
  3.     $replacespace = array('-', ',', '|', ' ', '_');
  4.     return trim(preg_replace($searchspace, $replacespace, str_replace($searchs, $replaces, $str)), ' ,-|_');
  5. }
复制代码
替换为:

  1. public static function strreplace_strip_split($searchs, $replaces, $str) {
  2.     $searchspace = array('(((\s)*\-(\s)*)+)', '(((\s)*\,(\s)*)+)', '(((\s)*\|(\s)*)+)', '(((\s)*\t(\s)*)+)', '(((\s)*_(\s)*)+)');
  3.     $replacespace = array('$3-$3', '$3,$3', '$3|$3', '$3 $3', '$3_$3');
  4.     return trim(preg_replace($searchspace, $replacespace, str_replace($searchs, $replaces, $str)), ' ,-|_');
  5. }
复制代码
上传到服务器后,刷新前台,即可看到效果。

全部评论 0

您需要登录后才可以回帖 立即登录
登录
0
0
0
返回顶部