prepare('SELECT * FROM categories WHERE key = ? LIMIT 1'); $st->execute([$catKey]); $cat = $st->fetch(); if (!$cat) { http_response_code(404); layout_head('导航页不存在'); echo '
导航分类不存在,请返回首页。
'; layout_theme_fab(); layout_footer(); echo ''; exit; } // 块与按钮数据 $st = $pdo->prepare('SELECT * FROM nav_blocks WHERE cat_id = ? ORDER BY sort ASC, id ASC'); $st->execute([(int)$cat['id']]); $blocks = $st->fetchAll(); $itemsByBlock = []; if ($blocks) { $ids = array_map(function ($b) { return (int)$b['id']; }, $blocks); $in = implode(',', array_fill(0, count($ids), '?')); $st = $pdo->prepare("SELECT * FROM nav_items WHERE block_id IN ($in) ORDER BY sort ASC, id ASC"); $st->execute($ids); foreach ($st->fetchAll() as $item) { $itemsByBlock[(int)$item['block_id']][] = $item; } } // 三列轮转分配(保证列内块数均衡) $cols = [[], [], []]; $idx = 0; foreach ($blocks as $b) { $cols[$idx % 3][] = $b; $idx++; } $totalItems = 0; foreach ($itemsByBlock as $list) { $totalItems += count($list); } $siteName = setting_get('site_name', '知识导航站'); $engines = search_engines(); $defaultEngine = $engines[0]['key'] ?? 'bing'; $enginesJson = json_encode($engines, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); layout_head((string)$cat['name']); ?>

可切换搜索引擎进行搜索( 个可用,后台可维护)