zzwy2/app/controller/Position.php

48 lines
1.6 KiB
PHP
Raw Normal View History

2022-10-08 09:31:39 +00:00
<?php
namespace app\controller;
use app\model\{Block, Category, PositionModel};
use think\Paginator;
class Position extends Base
{
//详情
public function detail($id = 0)
{
if ($id <= 0) {
return $this->error('错误页面');
}
$article = PositionModel::getById($id);
if (empty($article)) {
return $this->error('无此内容');
}
$category = Category::getById($article['category_id']);
$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);
2022-10-13 06:37:35 +00:00
$parentBlocks = Block::getByCategoryId($category['parent_id']);
$parentBlocks = Block::convertValue($parentBlocks);
$this->data['item'] = $article;
$this->data['category'] = $category;
// $blocks = Block::getByCategoryId($category['id']);
// $blocks = Block::convertValue($blocks);
// $this->data['blocks'] = $blocks;
$this->data['parentBlocks'] = $parentBlocks;
$this->data['categoryId'] = $category['id'];
$this->data['categoryPath'] = Category::categoryPath($category['path']);
$this->data['topCategoryId'] = Category::firstGradeId($category['path'], $category['id']);
return $this->view('/article/join_detail');
2022-10-08 09:31:39 +00:00
}
}