| 
									
										
										
										
											2022-10-08 17:31:39 +08:00
										 |  |  | <?php | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace app\controller; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | use app\model\{Category, Block, History, Honour, Model as MModel, Article as MArticle, PositionModel}; | 
					
						
							|  |  |  | use think\response\View; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class Page extends Base | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * @return View|void | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2022-10-11 10:23:21 +08:00
										 |  |  |     public function index($categoryId = 0) | 
					
						
							| 
									
										
										
										
											2022-10-08 17:31:39 +08:00
										 |  |  |     { | 
					
						
							|  |  |  |         $category = Category::getById($categoryId); | 
					
						
							|  |  |  |         if (!empty($category)) { | 
					
						
							|  |  |  |             $description = $category['seo_description'] ?: $this->system['seo_description']; | 
					
						
							|  |  |  |             $keywords    = $category['seo_keywords'] ?: $this->system['seo_keywords']; | 
					
						
							|  |  |  |             $title       = $category['seo_title'] ?: $category['title'].' | '.$this->system['seo_title']; | 
					
						
							|  |  |  |             $this->setSeo($title, $keywords, $description); | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |             $this->redirect('/404.html'); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2022-10-11 10:23:21 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-08 17:31:39 +08:00
										 |  |  |         $childCategory   = Category::getChildrenByParentId($category['id']); | 
					
						
							|  |  |  |         $parentCategory  = Category::getById($category['parent_id']); | 
					
						
							|  |  |  |         $brotherCategory = Category::getChildrenByParentId($category['parent_id']); | 
					
						
							|  |  |  |         $blocks          = Block::getByCategoryId($category['id']); | 
					
						
							|  |  |  |         $blocks          = Block::convertValue($blocks); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         // 父级单页配置的公共信息
 | 
					
						
							|  |  |  |         $parentBlocks = []; | 
					
						
							|  |  |  |         if (!empty($parentCategory) && $parentCategory['model_id'] == MModel::MODEL_PAGE) { | 
					
						
							|  |  |  |             $parentBlocks = Block::getByCategoryId($parentCategory['id']); | 
					
						
							|  |  |  |             $parentBlocks = Block::convertValue($parentBlocks); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-11 10:23:21 +08:00
										 |  |  |         $this->data['categoryPath']    = Category::categoryPath($category['path']); | 
					
						
							|  |  |  |         $this->data['topCategoryId']   = Category::firstGradeId($category['path'], $categoryId); | 
					
						
							| 
									
										
										
										
											2022-10-08 17:31:39 +08:00
										 |  |  |         $this->data['categoryId']      = $category['id']; | 
					
						
							|  |  |  |         $this->data['category']        = $category; | 
					
						
							|  |  |  |         $this->data['childCategory']   = $childCategory; | 
					
						
							|  |  |  |         $this->data['blocks']          = $blocks; | 
					
						
							|  |  |  |         $this->data['parentBlocks']    = $parentBlocks; | 
					
						
							|  |  |  |         $this->data['parentCategory']  = $parentCategory; | 
					
						
							|  |  |  |         $this->data['brotherCategory'] = $brotherCategory; | 
					
						
							|  |  |  |         $this->data['bodyClass']       = 'main'; | 
					
						
							|  |  |  |         $this->setExtraBaseConfig(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return $this->view($category['template_detail']); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } |