Files
YwxAppThink/addon/articles/controller/Index.php
T

48 lines
1.4 KiB
PHP

<?php
/*
* @Author: YwxApp <ywx@ywxapp.cn>
* @Date: 2026-08-10 15:31:01
* @LastEditors: YwxApp <ywx@ywxapp.cn>
* @LastEditTime: 2026-08-10 20:38:46
* @Description:
* @FilePath: \ywxapp_dev\addon\articles\controller\Index.php
* @CustomString: Copyright (c) 2026 YwxApp
*/
// +----------------------------------------------------------------------
// | YwxApp [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | 文章CMS前台首页
// +----------------------------------------------------------------------
declare (strict_types = 1);
namespace addon\articles\controller;
use addon\articles\model\Article;
use addon\articles\model\ArticleCategory;
class Index extends ArticlesFrontend
{
public function index()
{
// dump($this->app->route);die;
$page = (int) input('page', 1);
$list = Article::listArticles([], $page, 10);
// 轮播:取推荐或最新的 5 篇
$slides = Article::scope('normal')
->order('is_top desc, is_recommend desc, create_at desc')
->limit(5)
->field('id,title,cover_image')
->select();
$this->view->assign([
'list' => $list->items(),
'page' => $list->render(),
'slides' => $slides,
'nav_active' => 'index',
]);
return $this->fetch();
}
}