0) { $channel = $db->fetch("SELECT * FROM {$db->table('channel')} WHERE id=? AND is_show=1", [$id]); } // 根据栏目类型确定分类名称和数据 $typeConfig = [ 1 => ['label' => '新闻分类', 'table' => 'article'], 2 => ['label' => '产品分类', 'table' => 'product'], 3 => ['label' => '单页分类', 'table' => 'article'], 4 => ['label' => '图集分类', 'table' => 'image'], 5 => ['label' => '下载分类', 'table' => 'download'], 7 => ['label' => '视频分类', 'table' => 'video'], 8 => ['label' => '留言分类', 'table' => 'guestbook'], 9 => ['label' => '招聘分类', 'table' => 'recruit'], ]; $channelType = intval($channel['channel_type'] ?? 1); $cfg = $typeConfig[$channelType] ?? ['label' => '内容分类', 'table' => 'article']; $catLabel = $cfg['label']; $tbl = $cfg['table']; // 同类型所有栏目(用于左侧分类) $allSameTypeChannels = $db->fetchAll("SELECT * FROM {$db->table('channel')} WHERE channel_type = ? AND is_show = 1 ORDER BY list_order ASC, id ASC", [$channelType]); // 当前选中栏目 $curChannelId = isset($_GET['channel_id']) ? intval($_GET['channel_id']) : 0; // 按栏目筛选内容 $displayList = []; if ($curChannelId > 0) { $displayList = $db->fetchAll("SELECT * FROM {$db->table($tbl)} WHERE channel_id=? AND status=1 ORDER BY create_time DESC LIMIT 100", [$curChannelId]); } else { $channelIds = array_column($allSameTypeChannels, 'id'); if (!empty($channelIds)) { $placeholders = implode(',', array_fill(0, count($channelIds), '?')); $displayList = $db->fetchAll("SELECT * FROM {$db->table($tbl)} WHERE channel_id IN ({$placeholders}) AND status=1 ORDER BY create_time DESC LIMIT 100", $channelIds); } } ?>