51 lines
1.8 KiB
PHP
51 lines
1.8 KiB
PHP
<?php
|
||
/*
|
||
* @Author: YwxApp <ywx@ywxapp.cn>
|
||
* @Date: 2026-08-10 15:30:57
|
||
* @LastEditors: YwxApp <ywx@ywxapp.cn>
|
||
* @LastEditTime: 2026-08-13 17:38:27
|
||
* @Description:
|
||
* @FilePath: \ywxapp_dev\addon\articles\controller\ArticlesFrontend.php
|
||
* @CustomString: Copyright (c) 2026 YwxApp
|
||
*/
|
||
// +----------------------------------------------------------------------
|
||
// | YwxApp [ WE CAN DO IT JUST THINK ]
|
||
// +----------------------------------------------------------------------
|
||
// | 文章CMS前台基类:统一注入侧边栏/分类/标签等共享数据
|
||
// +----------------------------------------------------------------------
|
||
declare (strict_types = 1);
|
||
|
||
namespace addon\articles\controller;
|
||
|
||
use ywxapp\controller\FrontendBase;
|
||
use addon\articles\model\Article;
|
||
use addon\articles\model\ArticleCategory;
|
||
use addon\articles\model\ArticleTag;
|
||
use addon\articles\library\ArticleSchema;
|
||
|
||
class ArticlesFrontend extends FrontendBase
|
||
{
|
||
protected $noNeedLogin = ['*'];
|
||
protected $noNeedVerify = ['*'];
|
||
|
||
protected function initialize()
|
||
{
|
||
parent::initialize();
|
||
// articles 前台页面自带完整 <!DOCTYPE html> 结构,清空 layout_name,
|
||
// 避免被 common/layout 包裹导致双层 <html>、标签外露、排版错乱。
|
||
//$this->view->config(['layout_name' => '']);
|
||
ArticleSchema::ensure();
|
||
$isLogin = $this->auth && $this->auth->isLogin;
|
||
$loginUser = $isLogin ? $this->auth->info : null;
|
||
|
||
$this->view->assign([
|
||
'categories' => ArticleCategory::allEnable(),
|
||
'tags' => ArticleTag::where('delete_at', 0)->order('id', 'desc')->limit(20)->select(),
|
||
'hot' => Article::hot(10),
|
||
'is_login' => $isLogin,
|
||
'member' => $loginUser,
|
||
'nav_active' => '',
|
||
]);
|
||
}
|
||
}
|