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; } } $totalNav = 0; foreach ($itemsByBlock as $list) { $totalNav += count($list); } $navCols = [[], [], []]; $idx = 0; foreach ($blocks as $b) { $navCols[$idx % 3][] = $b; $idx++; } // —— 内部功能区数据(通用或包含当前库) —— $libTools = []; foreach ($pdo->query('SELECT * FROM func_tools WHERE enabled = 1 ORDER BY sort ASC, id ASC')->fetchAll() as $t) { if (board_cats_has((string) ($t['board_cats'] ?? ''), $catKey)) { $libTools[] = $t; } } // —— 文章区数据(仅分发到当前库;按分类分组,分类内按最后更新时间倒序) —— $libArts = []; foreach ($pdo->query('SELECT id, part, title, summary, updated_at, board_cats FROM articles WHERE enabled = 1 ORDER BY updated_at DESC, id DESC')->fetchAll() as $a) { if (in_array($catKey, array_map('trim', explode(',', trim((string) ($a['board_cats'] ?? '')))), true)) { $libArts[] = $a; } } // 按分类(part)分组;分类顺序:后台拖出的分区顺序优先,否则按各组最新更新时间降序 $artGroups = []; foreach ($libArts as $a) { $p = trim((string) $a['part']); if ($p === '') $p = '未分类'; if (!isset($artGroups[$p])) { $artGroups[$p] = ['ts' => (string) $a['updated_at'], 'items' => []]; } $artGroups[$p]['items'][] = $a; if (strcmp((string) $a['updated_at'], $artGroups[$p]['ts']) > 0) { $artGroups[$p]['ts'] = (string) $a['updated_at']; } } $poIdx = []; $poCfg = trim((string) setting_get('article_part_order', '')); if ($poCfg !== '') { foreach (explode(',', $poCfg) as $po) { $po = trim($po); if ($po !== '' && isset($artGroups[$po])) $poIdx[$po] = count($poIdx); } } uksort($artGroups, static function ($a, $b) use ($poIdx, $artGroups) { $ia = $poIdx[$a] ?? PHP_INT_MAX; $ib = $poIdx[$b] ?? PHP_INT_MAX; if ($ia !== $ib) return $ia <=> $ib; $d = strcmp($artGroups[$b]['ts'], $artGroups[$a]['ts']); return $d !== 0 ? $d : strcmp($a, $b); }); $artGroupOrder = []; foreach ($artGroups as $p => $g) { $artGroupOrder[] = ['p' => $p, 'items' => $g['items']]; } // —— 外部工具区数据(通用或包含当前库) —— $extLinks = []; foreach ($pdo->query('SELECT * FROM ext_links WHERE enabled = 1 ORDER BY sort ASC, id ASC')->fetchAll() as $e) { if (board_cats_has((string) ($e['cat_keys'] ?? ''), $catKey)) { $extLinks[] = $e; } } $siteName = setting_get('site_name', '知识导航站'); $engines = search_engines(); $defaultEngine = $engines[0]['key'] ?? 'bing'; $enginesJson = json_encode($engines, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); $domainOf = static function (string $u): string { $h = (string) parse_url($u, PHP_URL_HOST); return $h !== '' ? preg_replace('/^www\./i', '', $h) : $u; }; $catName = (string) $cat['name']; $catIcon = trim((string) $cat['icon']); layout_head($catName); ?>

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

导航区 ·

个导航块 / 个链接 · 悬停按钮可看备注
该库还没有导航内容,可在后台「导航管理」中添加

内部功能区 · 常用工具

前往完整功能区 ›
由后台「内部功能」为每个工具勾选“展示库”,未勾选默认出现在所有库。点击工具进入详情页(返回按钮已适配为返回上一页)。
尚未把工具分配到本库,可到后台「内部功能」开启

文章区 · 相关

前往完整文章库 ›
由后台「文章管理」为文章勾选分发到的库;点击进入阅读页(返回按钮已适配为返回上一页)。
还没有文章分发到本库,可到后台「文章管理」编辑文章并勾选“展示到库首页”

外部工具区 · 开源工具/好用站点/点开即用

快速链接 · 名称 · 简介 · 新标签页打开 · 后台可增删
由后台「外部工具」维护(可限制展示在特定库,留空则所有库通用)。
暂无外部工具,可到后台「外部工具」添加
$gItems): ?>