您现在的位置是:首页 >> 网站建设教程网站建设教程

pbootcms英文站搜索结果页面包屑和标题翻译

董哥2023-08-1533次围观

在使用pbootcms搭建英文站时会发现搜索结果页的面包屑为中文,标题为英文,该如何处理?可二开增加英文站对应文字来解决。

 

 

image.png

修改内容

打开ppshomecontrollerSearchController.php,把里面的代码全部替换成以下(分为2x和3x版本,对应版本替换):

pb2.1.1版本替换


 
  1. /**
  2.  * @copyright (C)2020-2099 Hnaoyun Inc.
  3.  * @author XingMeng
  4.  * @email hnxsh@foxmail.com
  5.  * @date 2020年3月8日
  6.  *  搜索控制器     
  7.  */
  8. namespace apphomecontroller;
  9.  
  10. use coreasicController;
  11.  
  12. class SearchController extends Controller
  13. {
  14.  
  15.     protected $parser;
  16.  
  17.     protected $htmldir;
  18.  
  19.     public function __construct()
  20.     {
  21.         $this->parser = new ParserController();
  22.         $this->htmldir = $this->config('tpl_html_dir') ? $this->config('tpl_html_dir') . '/' : '';
  23.     }
  24.  
  25.     // 内容搜索@mk-lang 增加英语
  26.     public function index()
  27.     {
  28.         if (cookie('lg') == 'cn') {
  29.             $searchtpl = request('searchtpl');
  30.             if (! preg_match('/^[w]+.html$/', $searchtpl)) {
  31.                 $searchtpl = 'search.html';
  32.             }
  33.             
  34.             $content = parent::parser($this->htmldir . $searchtpl); // 框架标签解析
  35.             $content = $this->parser->parserBefore($content); // CMS公共标签前置解析
  36.             $pagetitle = get('keyword') ? get('keyword') . '-' : '';
  37.             $content = str_replace('{pboot:pagetitle}', $this->config('search_title') ?: $pagetitle . '搜索结果-{pboot:sitetitle}-{pboot:sitesubtitle}', $content);
  38.             $content = $this->parser->parserPositionLabel($content, 0, '搜索', homeurl('search')); // CMS当前位置标签解析
  39.             $content = $this->parser->parserSpecialPageSortLabel($content, - 1, '搜索结果', homeurl('search')); // 解析分类标签
  40.             $content = $this->parser->parserSearchLabel($content); // 搜索结果标签
  41.             $content = $this->parser->parserAfter($content); // CMS公共标签后置解析
  42.             echo $content; // 搜索页面不缓存
  43.             exit();
  44.         } else {
  45.             $searchtpl = request('searchtpl');
  46.             if (! preg_match('/^[w]+.html$/', $searchtpl)) {
  47.                 $searchtpl = 'search.html';
  48.             }
  49.             
  50.             $content = parent::parser($this->htmldir . $searchtpl); // 框架标签解析
  51.             $content = $this->parser->parserBefore($content); // CMS公共标签前置解析
  52.             $pagetitle = get('keyword') ? get('keyword') . '-' : '';
  53.             $content = str_replace('{pboot:pagetitle}', $this->config('search_title') ?: $pagetitle . 'The search results-{pboot:sitetitle}-{pboot:sitesubtitle}', $content);
  54.             $content = $this->parser->parserPositionLabel($content, 0, 'Search', homeurl('search')); // CMS当前位置标签解析
  55.             $content = $this->parser->parserSpecialPageSortLabel($content, - 1, 'The search results', homeurl('search')); // 解析分类标签
  56.             $content = $this->parser->parserSearchLabel($content); // 搜索结果标签
  57.             $content = $this->parser->parserAfter($content); // CMS公共标签后置解析
  58.             echo $content; // 搜索页面不缓存
  59.             exit();
  60.         }
  61.     }
  62. }

pb3.0.3版本替换



 
  1. /**
  2.  * @copyright (C)2020-2099 Hnaoyun Inc.
  3.  * @author XingMeng
  4.  * @email hnxsh@foxmail.com
  5.  * @date 2020年3月8日
  6.  *  搜索控制器     
  7.  */
  8. namespace apphomecontroller;
  9.  
  10. use coreasicController;
  11. use coreasicUrl;
  12.  
  13. class SearchController extends Controller
  14. {
  15.  
  16.     protected $parser;
  17.  
  18.     protected $htmldir;
  19.  
  20.     public function __construct()
  21.     {
  22.         $this->parser = new ParserController();
  23.         $this->htmldir = $this->config('tpl_html_dir') ? $this->config('tpl_html_dir') . '/' : '';
  24.     }
  25.  
  26.     // 内容搜索
  27.     public function index()
  28.     {
  29.         if (cookie('lg') == 'cn') {
  30.             $searchtpl = request('searchtpl');
  31.             if (! preg_match('/^[w]+.html$/', $searchtpl)) {
  32.                 $searchtpl = 'search.html';
  33.             }
  34.             
  35.             $content = parent::parser($this->htmldir . $searchtpl); // 框架标签解析
  36.             $content = $this->parser->parserBefore($content); // CMS公共标签前置解析
  37.             $pagetitle = get('keyword') ? get('keyword') . '-' : '';
  38.             $content = str_replace('{pboot:pagetitle}', $this->config('search_title') ?: $pagetitle . '搜索结果-{pboot:sitetitle}-{pboot:sitesubtitle}', $content);
  39.             $content = $this->parser->parserPositionLabel($content, 0, '搜索', Url::home('search')); // CMS当前位置标签解析
  40.             $content = $this->parser->parserSpecialPageSortLabel($content, - 1, '搜索结果', Url::home('search')); // 解析分类标签
  41.             $content = $this->parser->parserSearchLabel($content); // 搜索结果标签
  42.             $content = $this->parser->parserAfter($content); // CMS公共标签后置解析
  43.             echo $content; // 搜索页面不缓存
  44.             exit();
  45.         } else {
  46.             $searchtpl = request('searchtpl');
  47.             if (! preg_match('/^[w]+.html$/', $searchtpl)) {
  48.                 $searchtpl = 'search.html';
  49.             }
  50.             
  51.             $content = parent::parser($this->htmldir . $searchtpl); // 框架标签解析
  52.             $content = $this->parser->parserBefore($content); // CMS公共标签前置解析
  53.             $pagetitle = get('keyword') ? get('keyword') . '-' : '';
  54.             $content = str_replace('{pboot:pagetitle}', $this->config('search_title') ?: $pagetitle . 'The search results-{pboot:sitetitle}-{pboot:sitesubtitle}', $content);
  55.             $content = $this->parser->parserPositionLabel($content, 0, 'Search', Url::home('search')); // CMS当前位置标签解析
  56.             $content = $this->parser->parserSpecialPageSortLabel($content, - 1, 'The search results', Url::home('search')); // 解析分类标签
  57.             $content = $this->parser->parserSearchLabel($content); // 搜索结果标签
  58.             $content = $this->parser->parserAfter($content); // CMS公共标签后置解析
  59.             echo $content; // 搜索页面不缓存
  60.             exit();
  61.         }
  62.     }
  63. }

替换效果

image.png

 

标签云

站点信息