TagController.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 TagController 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. // 在非兼容模式接受地址第二参数值
  25. if (defined('RVAR')) {
  26. $_GET['tag'] = RVAR;
  27. }
  28. if (! get('tag')) {
  29. _404('您访问的页面不存在,请核对后重试!');
  30. }
  31. $tagstpl = request('tagstpl');
  32. if (! preg_match('/^[\w]+\.html$/', $tagstpl)) {
  33. $tagstpl = 'tags.html';
  34. }
  35. $content = parent::parser($this->htmldir . $tagstpl); // 框架标签解析
  36. $content = $this->parser->parserBefore($content); // CMS公共标签前置解析
  37. $content = $this->parser->parserPositionLabel($content, 0, '相关内容', Url::home('tag/' . get('tag'))); // CMS当前位置标签解析
  38. $content = $this->parser->parserSpecialPageSortLabel($content, - 2, '相关内容', Url::home('tag/' . get('tag'))); // 解析分类标签
  39. $content = $this->parser->parserAfter($content); // CMS公共标签后置解析
  40. $this->cache($content, true);
  41. }
  42. }