keyword = $params['keyword'] ?? $keyword; $this->page = $params['page'] ?? $page; $this->pageSize = $params['page_size'] ?? $pageSize; $this->typeId = $params['type_id'] ?? $typeId; $this->tagId = $params['tag_id'] ?? $tagId; $this->router_path = $params['router_path'] ?? $routerPath; $this->plate_id = $params['plate_id'] ?? $plateId; if (empty($this->plate_id)) { $this->plate_id = BlogPlateModel::NEWS; } if (empty($params['sort'])) { $this->sort = ['pub_date']; } else { $this->sort = $params['sort']; } $this->echo_content = $params['echo_content'] ?? $echoContent; $this->viewFile = $viewFile; } /** * 资讯列表组件 */ public function render() { $retData = [ 'recent_news_list' => [] ]; $retData['news_list'] = BlogRenderFacade::getPublishBlogList( $this->plate_id, $this->keyword, $this->page, $this->pageSize, $this->sort, $this->typeId, $this->tagId, null, $this->echo_content ); if (!empty($this->typeId)) { $retData['blog_type_info'] = BlogRenderFacade::getBlogTypeInfo($this->typeId); // dd($retData); } $retData['type_items'] = BlogRenderFacade::getPublishedTypeList($this->plate_id); $retData['tag_items'] = BlogRenderFacade::getPublishedTagList($this->plate_id); if (!empty($this->router_path)) { $pageContent = WebFacade::getStaticPageInfo(['route_path' => $this->router_path]); $layoutContent = WebFacade::getStaticPageInfo(['route_path' => WebService::LAYOUTS_ROUTE]); if (!empty($layoutContent['page_content'])) { foreach ($layoutContent['page_content'] as $key => $content_item) { if (empty($pageContent['page_content'][$key])) { $pageContent['page_content'][$key] = $content_item; } } } $retData['page_content'] = $pageContent['page_content']; } $retData['menu_data']=WebFacade::getWebMenu(); return view($this->viewFile, $retData); } }