chaoyu/app/controller/Page.php

45 lines
1.4 KiB
PHP

<?php
namespace app\controller;
use app\model\{Category, Block};
class Page extends Base
{
private function getPageCommonData($categoryId)
{
$resp = true;
$category = Category::getById($categoryId);
if ($category) {
$description = $category['description'] ? $category['description'] : $this->system['seo_description'];
$this->setSeo($category['title'], $this->system['seo_keywords'], $description);
} else {
$resp = false;
}
$childCategory = Category::getChildrenByParentId($categoryId);
$this->data['categoryId'] = $categoryId;
$this->data['category'] = $category;
$this->data['childCategory'] = $childCategory;
$this->data['blocks'] = Block::getByCategoryId($categoryId);
return $resp;
}
// 默认单页页面
public function index($categoryId)
{
$resp = $this->getPageCommonData($categoryId);
if(!$resp) {
return $this->error('错误页面');
}
return $this->view($this->data['category']['template_detail']);
}
// 营销页面
public function marketing($categoryId)
{
$resp = $this->getPageCommonData($categoryId);
if(!$resp) {
return $this->error('错误页面');
}
return $this->view($this->data['category']['template_detail']);
}
}