* Date: 2026-5-20
*/
if (!defined('ROOT_PATH')) { exit('Access Denied'); }
require_once __DIR__ . '/../_functions.php';
$articleChannels = $db->fetchAll("SELECT * FROM {$db->table('channel')} WHERE channel_type = 1 AND is_show = 1 ORDER BY list_order ASC, id ASC");
$filterChannelId = intval($_GET['channel_id'] ?? 0);
$currentPage = max(1, intval($_GET['page'] ?? 1));
$pageSize = 8;
$heroChannel = !empty($articleChannels[0]) ? $articleChannels[0] : ['channel_name' => '新闻资讯', 'channel_thumb' => ''];
$heroImage = k607_channel_hero_image($heroChannel, !empty($slides[0]['litpic']) ? $slides[0]['litpic'] : '');
$pageTitle = '新闻资讯';
$where = " WHERE a.status = 1";
$params = [];
if ($filterChannelId > 0) {
$where .= " AND a.channel_id = ?";
$params[] = $filterChannelId;
}
$countRow = $db->fetch("SELECT COUNT(*) AS total FROM {$db->table('article')} a{$where}", $params);
$total = intval($countRow['total'] ?? 0);
$totalPages = max(1, (int) ceil($total / $pageSize));
$offset = ($currentPage - 1) * $pageSize;
$items = $db->fetchAll("SELECT a.*, c.channel_name FROM {$db->table('article')} a LEFT JOIN {$db->table('channel')} c ON a.channel_id = c.id{$where} ORDER BY a.create_time DESC LIMIT {$offset}, {$pageSize}", $params);
require_once __DIR__ . '/../_header.php';
?>