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

其实在在 DZ2.0 中就出现过类似的 BUG,但官方好像一直也没有理会,现在升级到3.2版本后,这个问题还是没有得到解决,下面就分享下儿童安全座椅网(http://www.bbseat.com.cn)就此问题的解决方案:

在文件:source\class\helper\helper_seo.php,49行附近,找到如下代码(修改之前请备份好原文件):

public static function strreplace_strip_split($searchs, $replaces, $str) {
    $searchspace = array('((\s*\-\s*)+)', '((\s*\,\s*)+)', '((\s*\|\s*)+)', '((\s*\t\s*)+)', '((\s*_\s*)+)');
    $replacespace = array('-', ',', '|', ' ', '_');
    return trim(preg_replace($searchspace, $replacespace, str_replace($searchs, $replaces, $str)), ' ,-|_');
}

替换为:

public static function strreplace_strip_split($searchs, $replaces, $str) {
    $searchspace = array('(((\s)*\-(\s)*)+)', '(((\s)*\,(\s)*)+)', '(((\s)*\|(\s)*)+)', '(((\s)*\t(\s)*)+)', '(((\s)*_(\s)*)+)');
    $replacespace = array('$3-$3', '$3,$3', '$3|$3', '$3 $3', '$3_$3');
    return trim(preg_replace($searchspace, $replacespace, str_replace($searchs, $replaces, $str)), ' ,-|_');
}

上传到服务器后,刷新前台,即可看到效果。

相关文章:

  • 2022-01-11
  • 2022-01-12
  • 2022-01-27
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-08-06
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-14
  • 2021-09-23
  • 2022-02-25
相关资源
相似解决方案