PageController.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2013-2019 http://www.thinkcmf.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8. // +----------------------------------------------------------------------
  9. // | Author: 老猫 <thinkcmf@126.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\portal\controller;
  12. use cmf\controller\HomeBaseController;
  13. use app\portal\service\PostService;
  14. class PageController extends HomeBaseController
  15. {
  16. /**
  17. * 页面管理
  18. * @return mixed
  19. * @throws \think\db\exception\DataNotFoundException
  20. * @throws \think\db\exception\ModelNotFoundException
  21. * @throws \think\exception\DbException
  22. */
  23. public function index()
  24. {
  25. $postService = new PostService();
  26. $pageId = $this->request->param('id', 0, 'intval');
  27. $page = $postService->publishedPage($pageId);
  28. if (empty($page)) {
  29. abort(404, ' 页面不存在!');
  30. }
  31. $this->assign('page', $page);
  32. $more = $page['more'];
  33. $tplName = empty($more['template']) ? 'page' : $more['template'];
  34. return $this->fetch("/$tplName");
  35. }
  36. }