心理咨询网
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

SearchController.php 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /**
  3. * @copyright (C)2020-2099 Hnaoyun Inc.
  4. * @author XingMeng
  5. * @email hnxsh@foxmail.com
  6. * @date 2020年3月8日
  7. * 搜索控制器
  8. */
  9. namespace app\home\controller;
  10. use core\basic\Controller;
  11. use core\basic\Url;
  12. class SearchController extends Controller
  13. {
  14. protected $parser;
  15. protected $htmldir;
  16. public function __construct()
  17. {
  18. $this->parser = new ParserController();
  19. $this->htmldir = $this->config('tpl_html_dir') ? $this->config('tpl_html_dir') . '/' : '';
  20. }
  21. // 内容搜索
  22. public function index()
  23. {
  24. $searchtpl = request('searchtpl');
  25. if (! preg_match('/^[\w]+\.html$/', $searchtpl)) {
  26. $searchtpl = 'search.html';
  27. }
  28. $content = parent::parser($this->htmldir . $searchtpl); // 框架标签解析
  29. $content = $this->parser->parserBefore($content); // CMS公共标签前置解析
  30. $pagetitle = get('keyword', 'var') ? get('keyword', 'var') . '-' : '';
  31. $content = str_replace('{pboot:pagetitle}', $this->config('search_title') ?: $pagetitle . '搜索结果-{pboot:sitetitle}-{pboot:sitesubtitle}', $content);
  32. $content = $this->parser->parserPositionLabel($content, 0, '搜索', Url::home('search')); // CMS当前位置标签解析
  33. $content = $this->parser->parserSpecialPageSortLabel($content, - 1, '搜索结果', Url::home('search')); // 解析分类标签
  34. $content = $this->parser->parserSearchLabel($content); // 搜索结果标签
  35. $content = $this->parser->parserAfter($content); // CMS公共标签后置解析
  36. echo $content; // 搜索页面不缓存
  37. exit();
  38. }
  39. }