万年历主题模板 V1.6
主题分类: 传统文化
CMS版本: 最低 V 7.0
主题价格: 免费
发布日期: 2026-09-28 11:50:35
下载安装 提示:下载为默认主题,必须登后台--主题中心--安装万年历主题模板方可。

万年历主题模板 主题说明

简介:专为"万年历 / 老黄历"场景打造的响应式主题,涵盖黄历日历、黄道吉日、放假安排、节日表、24节气、老黄历详情等场景,对接逗号API实时拉取黄历数据。

主题概览

「万年历主题模板」是逗号CMS官方推出的一款行业主题,专为万年历、老黄历类网站设计。主题内含 黄历日历首页、黄道吉日大全、黄道吉日详情、放假安排、节日表、24节气表、老黄历日期详情、文章分类、文章详情 等页面,整站采用中国红 + 富贵金的喜庆配色,结合传统书法字体背景装饰,营造传统择吉文化的厚重感。

重要提醒:所有吉日数据都是由专业老师来梳理要点指导完成,宜忌都是根据十二建除、廿八星宿先筛,后根据黄道和黑道来兜底,非常专业。但是仅供语娱乐参考哦。

主题截图

首页截图
首页截图
黄道吉日页面截图
黄道吉日页面截图
具体吉日查询截图
具体吉日查询截图
放假安排页面截图
放假安排页面截图
节日页面截图
节日页面截图
文章列表截图
文章列表截图

安装方法

  1. 下载逗号CMS → 登录后台 → 主题管理 → 主题列表,找到「万年历主题模板」主题,点击免费安装
  1. 进入后台 → 网站设置 → SEO 设置,配置首页、文章分类列表页、文章详情页的 SEO 信息。可选:打开模板/templates/jiri/header.php,修改配置各页面的 SEO 信息。
  2. 进入 后台 → 网站设置 → 顶部导航,配置顶部导航及链接。
  3. 进入后台 → 网站设置,设置联盟ID。改为你自己在伍柒联盟union.632757.com的ID(右上角),所有黄道吉日中付费项目收益就像归于您自己名下。【说明:不要此付费项目功能,自行到hdjr_detail.php删除即可】
必看 页面显示403、万年历没有数据怎么办?
  1. 显示403:复制下面前端路由规则代码到:后台 → 管理 → 前端路由管理 → 全选覆盖路由规则 → 保存配置即可
  2. 万年历依赖API,如果发现没有出数据:登录逗号API后台 → 查看顶部积分是否充足,积分不足充值积分或者加盟代理即可。

配置 API

万年历依赖「逗号API」接口老黄历日历详版 :https://api.douhao.com/jie/16.html
这个老黄历是只要出结果就是调用,所以初始安装没有缓存调用会比较频繁,每次调用将消耗1积分(注册有赠送50积分),不过我们每个日期系统都自动缓存,头几天调用消耗可能比较快,后续就很少了。所以不要觉得消耗快用不起。

建议:199元/年初级代理就可以每天免费1万次。,新站包你够用,超出全免。

代理权益列表:https://api.douhao.com/daili 。

也可以 充值积分 还可以 推广获积分

获取 API 密钥

  1. 访问 逗号API网站 注册账号
  2. 登录后台首页,复制「API密钥」

配置 API 密钥

  1. 您的网站后台 → 网站设置(或主题中心)
  2. 在「逗号API密钥」输入框粘贴密钥--保存设置

接口参数一览

API接口api_idAPI接口网址
老黄历日历详情16https://api.douhao.com/jie/16.html
老黄历吉日查询69https://api.douhao.com/jie/69.html
如积分不足,请前往逗号API网站充值。账户积分与文章生成价格可在「AI自动撰文」页面查看。

SEO修改位置

万年历主题的 SEO 有两个来源,修改前先确认当前页面走的是哪条路径:①页面文件预设(优先,页面文件在 include header.php 之前定义 $GLOBALS['wnl_seo']);②header.php 自动生成(兜底,走 URL 匹配或 $wnl_static_seo 静态表)。

各页面 SEO 修改位置总表

页面访问路径SEO 来源修改位置
首页/后台数据库后台 → 网站设置 → SEO设置 → 首页
日期详情页/wnl/yyyyMMdd.html页面文件templates/wnl/day.php 中 $GLOBALS['wnl_seo']
黄道吉日首页/hdjrheader.php 兜底templates/wnl/header.php 中 $wnl_static_seo['hdjr']
黄道吉日详情/hdjr/{吉日}?{年}页面文件templates/wnl/hdjr_detail.php 顶部 $GLOBALS['wnl_seo']
放假安排/jiaqi?{年}页面文件templates/wnl/jiaqi.php 顶部 $GLOBALS['wnl_seo']
节日表/jieri?{年}页面文件templates/wnl/jieri.php 顶部 $GLOBALS['wnl_seo']
24节气/jieqi?{年}页面文件templates/wnl/jieqi.php 顶部 $GLOBALS['wnl_seo']
全部文章 / 分类/list.html、/category-x.html后台数据库后台 → 网站设置 → SEO设置 → 文章分类页
文章详情/article-x.html后台数据库后台 → 网站设置 → SEO设置 → 文章详情页
搜索结果/rs/{关键词}header.php 自动后台 → 网站设置 → SEO设置 → 搜索页(当前模板未单独接)
热搜标签聚合/rsheader.php 自动后台 → 网站设置 → SEO设置 → 搜索聚合页(当前模板未单独接)

最常用的修改位置速查

改哪个去哪里改
首页标题关键词描述后台 SEO设置 → 首页
文章详情页标题模板后台 SEO设置 → 文章详情页
分类页标题模板后台 SEO设置 → 文章分类页
日期详情页 SEOtemplates/wnl/day.php 里的 $GLOBALS['wnl_seo']
吉日详情 SEOtemplates/wnl/hdjr_detail.php 里的 $GLOBALS['wnl_seo']
放假安排 SEOtemplates/wnl/jiaqi.php 里的 $GLOBALS['wnl_seo']
节日表 SEOtemplates/wnl/jieri.php 里的 $GLOBALS['wnl_seo']
24节气 SEOtemplates/wnl/jieqi.php 里的 $GLOBALS['wnl_seo']
黄道吉日首页 SEOtemplates/wnl/header.php 里的 $wnl_static_seo['hdjr']

可用标签变量

在 $GLOBALS['wnl_seo'] 里可以直接写 {site_name}(自动替换成网站名称)。部分页面还预设了额外的变量:

变量适用页面含义
{site_name}所有页面网站名称
$hl_solar_strday.php公历字符串(如 2026年8月31日)
$hl_lunar_strday.php农历字符串(如 七月初八)
$hl_ganzhi_strday.php干支字符串(如 丙午年 丙申月 戊申日)
$query_yearhdjr_detail.php、jiaqi.php、jieri.php、jieqi.php年份(如 2026)
$slughdjr_detail.php吉日类型(如 结婚、开业)
修改后如需刷新前台效果,可先清空 /cache/front_route_cache.php 和浏览器缓存(Ctrl+F5)。若开启了页面静态缓存,还需到「缓存管理」清空对应类型缓存。
升级主题时,模板文件会整体覆盖。若希望 SEO 修改长期生效,优先走后台「SEO设置」,避免直接改模板文件。

功能特色

月度黄历日历

首页展示月度日历,每个日期同时显示公历、农历、节气、节日、休班标记,鼠标悬停日期直达详情。

黄道吉日大全

汇集嫁娶、开市、动土、入宅、出行、祭祀等数十种黄道吉日分类,可跳转各类型吉日详情。

吉日详情页

展示全年该吉日类型的所有可用日期,含农历、干支、值神、建除十二神、二十八星宿等完整信息。

放假安排

展示全年的法定节假日放假及调休安排,含节日标签,点击日期直达老黄历详情。

节日表

完整收录全年阳历、农历节日,含元旦、春节、清明、中秋、国庆等重大节日与各类纪念日。

24节气

全年 24 节气精确日期一览,含节气简介与相关联的日期详情。

老黄历详情

按天展示黄历完整信息:宜忌、值神、冲煞、财神方位、吉神凶煞、彭祖百忌、时辰吉凶等。

PC/手机自适应

一套模板自动适配各种屏幕尺寸,手机端日历、吉日卡片、时辰列表布局经过专门优化。

广告位支持

顶部横幅广告位,可在后台「广告管理 → 网站横幅」中配置图片/代码/文字广告。

页面列表

主题包含以下页面文件,全部位于 /templates/wnl/ 目录:

文件名页面说明URL
header.php公共头部(导航 + SEO)-
footer.php公共底部-
index.php黄历日历首页/
hdjr.php黄道吉日大全/hdjr
hdjr_detail.php黄道吉日详情/hdjr/{吉日名}
hdjr_forms.php吉日表单合集(被详情页调用)-
jiaqi.php放假安排/jiaqi
jieri.php节日表/jieri
jieqi.php24节气表/jieqi
day.php老黄历日期详情/wnl/yyyyMMdd.html
laohuangli_class.php公历转农历核心类-
holiday_config.php节假日/农历/节气配置数据-
category.php文章分类列表页/list.html、/category-x.html
article.php文章详情页/article-x.html

其他资源

文件说明
/templates/wnl/css/style.css主题全局样式
/templates/wnl/js/index.js首页交互脚本
/templates/wnl/images/union.js第三方跳转公共逻辑
/templates/wnl/images/yjt.png日期卡片右侧箭头图标

广告位配置

万年历主题中,所有页面顶部都调用了「网站横幅」广告位:

<!-- ========== 网站横幅 ========== -->
<?php echo get_ad_position('header_banner'); ?>

如何配置顶部横幅广告?

  1. 后台 → 内容管理 → 广告管理
  2. 找到 「网站横幅」 广告位,点击「广告设置」
  3. 点击「添加广告」,填写标题、选择投放页面(首页/分类页/文章详情/产品分类/产品详情)
  4. 选择广告模板(图片/代码/文字)
  5. 设置排序、状态(启用),保存
如需不同页面显示不同广告图,可在后台新增广告位,然后将对应的调用代码复制到相应页面的横幅区域即可。

前端路由规则

<?php
/**
 * 逗号CMS - 前端路由配置(万年历专版)
 */

function parse_rewrite_url($uri, $setting, $db, $prefix) {
    if ($uri === '/ubb' || $uri === '/ubb/') {
        return 'ubb_index';
    }
    if (preg_match('/^\/ubb\/([a-zA-Z0-9_\-]+)\/?$/', $uri, $matches)) {
        $_GET['slug'] = $matches[1];
        return 'ubb_page';
    }

    if ($uri === '/rs' || $uri === '/rs/') {
        return 'search_rs_index';
    }

    if (preg_match('/^\/rs\/(.+?)\/?$/', $uri, $matches)) {
        $keyword = urldecode($matches[1]);
        $keyword = trim($keyword);
        if ($keyword !== '') {
            $_GET['keyword'] = $keyword;
            return 'search';
        }
    }

    if (preg_match('/^\/hdjr\/([^\/?]+)\/?$/', $uri, $matches)) {
        $slug = urldecode($matches[1]);
        if ($slug !== '') {
            $_GET['slug'] = $slug;
            return 'hdjr_detail';
        }
    }

    if ($uri === '/hdjr' || $uri === '/hdjr/') {
        return 'hdjr';
    }

    if ($uri === '/jiaqi' || $uri === '/jiaqi/') {
        return 'jiaqi';
    }

    if ($uri === '/jieri' || $uri === '/jieri/') {
        return 'jieri';
    }

    if ($uri === '/jieqi' || $uri === '/jieqi/') {
        return 'jieqi';
    }

    if (preg_match('/^\/wnl\/(\d{8})\.html$/', $uri, $matches)) {
        $date_str = $matches[1];
        $date = substr($date_str, 0, 4) . '-' . substr($date_str, 4, 2) . '-' . substr($date_str, 6, 2);
        $_GET['date'] = $date;
        return 'wnl_day';
    }

    $article_prefix = preg_quote($setting['article_prefix'] ?? 'article-', '/');
    if (preg_match('/^\/' . $article_prefix . '([0-9a-zA-Z]+)\.html$/', $uri, $matches)) {
        $url_id = $matches[1];
        if ($setting['url_mode'] == 1) {
            $_GET['id'] = intval($url_id);
        } else {
            $field = ($setting['url_mode'] == 2) ? 'hash_id' : 'md5_id';
            $stmt = $db->prepare("SELECT id FROM {$prefix}article WHERE $field = ? LIMIT 1");
            if ($stmt) {
                $stmt->bind_param("s", $url_id);
                $stmt->execute();
                $res = $stmt->get_result();
                if ($res && $res->num_rows > 0) {
                    $row = $res->fetch_assoc();
                    $_GET['id'] = $row['id'];
                } else {
                    http_response_code(404);
                    require_once ROOT_PATH . '/set/404.php';
                    exit;
                }
                $stmt->close();
            } else {
                http_response_code(404);
                require_once ROOT_PATH . '/set/404.php';
                exit;
            }
        }
        return 'article';
    }
    
    $category_prefix = preg_quote($setting['category_prefix'] ?? 'category-', '/');
    if (preg_match('/^\/' . $category_prefix . '([0-9a-zA-Z]+)\.html$/', $uri, $matches)) {
        $url_id = $matches[1];
        $cat_url_mode = $setting['category_url_mode'] ?? 1;
        if ($cat_url_mode == 1) {
            $_GET['id'] = intval($url_id);
        } else {
            $field = ($cat_url_mode == 2) ? 'hash_id' : 'md5_id';
            $stmt = $db->prepare("SELECT id FROM {$prefix}category WHERE $field = ? LIMIT 1");
            if ($stmt) {
                $stmt->bind_param("s", $url_id);
                $stmt->execute();
                $res = $stmt->get_result();
                if ($res && $res->num_rows > 0) {
                    $row = $res->fetch_assoc();
                    $_GET['id'] = $row['id'];
                } else {
                    http_response_code(404);
                    require_once ROOT_PATH . '/set/404.php';
                    exit;
                }
                $stmt->close();
            } else {
                http_response_code(404);
                require_once ROOT_PATH . '/set/404.php';
                exit;
            }
        }
        return 'category';
    }
    
    if (preg_match('/^\/product\.html$/', $uri)) {
        return 'product_list';
    }
    
    $product_category_prefix = preg_quote($setting['product_category_prefix'] ?? 'product-category-', '/');
    if (preg_match('/^\/' . $product_category_prefix . '([0-9a-zA-Z]+)\.html$/', $uri, $matches)) {
        $url_id = $matches[1];
        $product_cat_url_mode = $setting['product_category_url_mode'] ?? 1;
        if ($product_cat_url_mode == 1) {
            $_GET['id'] = intval($url_id);
        } else {
            $field = ($product_cat_url_mode == 2) ? 'hash_id' : 'md5_id';
            $stmt = $db->prepare("SELECT id FROM {$prefix}product_category WHERE $field = ? LIMIT 1");
            if ($stmt) {
                $stmt->bind_param("s", $url_id);
                $stmt->execute();
                $res = $stmt->get_result();
                if ($res && $res->num_rows > 0) {
                    $row = $res->fetch_assoc();
                    $_GET['id'] = $row['id'];
                } else {
                    http_response_code(404);
                    require_once ROOT_PATH . '/set/404.php';
                    exit;
                }
                $stmt->close();
            } else {
                http_response_code(404);
                require_once ROOT_PATH . '/set/404.php';
                exit;
            }
        }
        return 'product_list';
    }
    
    $product_prefix = preg_quote($setting['product_prefix'] ?? 'product-', '/');
    if (preg_match('/^\/' . $product_prefix . '([0-9a-zA-Z]+)\.html$/', $uri, $matches)) {
        $url_id = $matches[1];
        $product_url_mode = $setting['product_url_mode'] ?? 1;
        if ($product_url_mode == 1) {
            $_GET['id'] = intval($url_id);
        } else {
            $field = ($product_url_mode == 2) ? 'hash_id' : 'md5_id';
            $stmt = $db->prepare("SELECT id FROM {$prefix}product WHERE $field = ? LIMIT 1");
            if ($stmt) {
                $stmt->bind_param("s", $url_id);
                $stmt->execute();
                $res = $stmt->get_result();
                if ($res && $res->num_rows > 0) {
                    $row = $res->fetch_assoc();
                    $_GET['id'] = $row['id'];
                } else {
                    http_response_code(404);
                    require_once ROOT_PATH . '/set/404.php';
                    exit;
                }
                $stmt->close();
            } else {
                http_response_code(404);
                require_once ROOT_PATH . '/set/404.php';
                exit;
            }
        }
        return 'product_detail';
    }
    
    if ($uri === '/list.html' || preg_match('/^\/list-([0-9]+)\.html$/', $uri, $matches)) {
        if (isset($matches[1])) $_GET['page'] = intval($matches[1]);
        return 'list';
    }
    
    if ($uri === '/' || $uri === '/index.php') {
        return 'index';
    }
    
    return '404';
}

function route_dispatch($action, $db, $prefix, $setting, $template_path) {
    if ($action === '404') {
        http_response_code(404);
        require_once ROOT_PATH . 'set/404.php';
        exit;
    }

    if ($action === 'hdjr_detail') {
        include $template_path . 'header.php';
        include $template_path . 'hdjr_detail.php';
        include $template_path . 'footer.php';
        return true;
    }

    if ($action === 'hdjr') {
        include $template_path . 'header.php';
        include $template_path . 'hdjr.php';
        include $template_path . 'footer.php';
        return true;
    }

    if ($action === 'jiaqi') {
        include $template_path . 'header.php';
        include $template_path . 'jiaqi.php';
        include $template_path . 'footer.php';
        return true;
    }

    if ($action === 'jieri') {
        include $template_path . 'header.php';
        include $template_path . 'jieri.php';
        include $template_path . 'footer.php';
        return true;
    }

    if ($action === 'jieqi') {
        include $template_path . 'header.php';
        include $template_path . 'jieqi.php';
        include $template_path . 'footer.php';
        return true;
    }

    if ($action === 'wnl_day') {
        include $template_path . 'header.php';
        include $template_path . 'day.php';
        include $template_path . 'footer.php';
        return true;
    }

    if ($action === 'ubb_index') {
        $seo_row = $db->query("SELECT * FROM {$prefix}seo WHERE page_name = 'ubb_index' LIMIT 1")->fetch_assoc();
        $site_name = $setting['site_name'] ?? '逗号CMS';
        if ($seo_row) {
            $seo = [
                'title' => str_replace('{site_name}', $site_name, $seo_row['title'] ?: ('留言本 - ' . $site_name)),
                'keywords' => str_replace('{site_name}', $site_name, $seo_row['keywords']),
                'description' => str_replace('{site_name}', $site_name, $seo_row['description']),
            ];
        } else {
            $seo = [
                'title' => '留言本 - ' . $site_name,
                'keywords' => '留言本,在线留言,反馈',
                'description' => '欢迎使用在线留言本,选择您想要留言的页面'
            ];
        }
        include $template_path . 'header.php';
        require ROOT_PATH . 'set/ubb/index.php';
        include $template_path . 'footer.php';
        return true;
    }

    if ($action === 'ubb_page') {
        $slug = isset($_GET['slug']) ? trim($_GET['slug']) : '';
        $page_info_row = $db->query("SELECT * FROM {$prefix}ubb_pages WHERE slug = '" . $db->real_escape_string($slug) . "' AND status = 1 LIMIT 1")->fetch_assoc();
        $site_name = $setting['site_name'] ?? '逗号CMS';
        if ($page_info_row) {
            $seo_row = $db->query("SELECT * FROM {$prefix}seo WHERE page_name = 'ubb_page' LIMIT 1")->fetch_assoc();
            $replace_map = [
                '{page_name}' => $page_info_row['name'],
                '{page_description}' => $page_info_row['description'] ?: $page_info_row['name'],
                '{site_name}' => $site_name,
            ];
            if ($seo_row) {
                $seo = [
                    'title' => str_replace(array_keys($replace_map), array_values($replace_map), $seo_row['title'] ?: ($page_info_row['name'] . ' - ' . $site_name)),
                    'keywords' => str_replace(array_keys($replace_map), array_values($replace_map), $seo_row['keywords']),
                    'description' => str_replace(array_keys($replace_map), array_values($replace_map), $seo_row['description']),
                ];
            } else {
                $seo = [
                    'title' => $page_info_row['name'] . ' - ' . $site_name,
                    'keywords' => $page_info_row['name'],
                    'description' => $page_info_row['description'] ?: $page_info_row['name']
                ];
            }
        } else {
            $seo = [
                'title' => '留言页 - ' . $site_name,
                'keywords' => '',
                'description' => ''
            ];
        }
        include $template_path . 'header.php';
        require ROOT_PATH . 'set/ubb/page.php';
        include $template_path . 'footer.php';
        return true;
    }

    if ($action === 'search_rs_index') {
        $site_name = $setting['site_name'] ?? '逗号CMS';
        $seo_row = $db->query("SELECT * FROM {$prefix}seo WHERE page_name = 'search_rs_index' LIMIT 1")->fetch_assoc();
        if ($seo_row) {
            $seo = [
                'title' => str_replace('{site_name}', $site_name, $seo_row['title'] ?: ('热搜标签 - ' . $site_name)),
                'keywords' => str_replace('{site_name}', $site_name, $seo_row['keywords']),
                'description' => str_replace('{site_name}', $site_name, $seo_row['description']),
            ];
        } else {
            $seo = [
                'title' => '热搜标签 - ' . $site_name,
                'keywords' => '热搜,标签,热门搜索',
                'description' => '网站热搜标签聚合页'
            ];
        }
        include $template_path . 'header.php';
        include $template_path . 'search_rs.php';
        include $template_path . 'footer.php';
        return true;
    }

    if ($action === 'search') {
        $_GET['action'] = 'search';
        $keyword = isset($_GET['keyword']) ? trim($_GET['keyword']) : '';
        $keyword_display = $keyword;
        if (!empty($keyword)) {
            if (!check_sensitive_words($keyword)) {
                http_response_code(404);
                require_once ROOT_PATH . 'set/404.php';
                exit;
            }
            record_hot_search($keyword);
            $keyword_escaped = str_replace(['%', '_'], ['\\%', '\\_'], $keyword);
            save_search_keyword($keyword_escaped);

            $keywords = split_search_keywords($keyword);
            $page = isset($_GET['page']) ? max(1, intval($_GET['page'])) : 1;
            $page_size = 20;
            $search_result = search_articles_by_keywords($keywords, $page, $page_size);
            $articles = $search_result['articles'];
            $total = $search_result['total'];
            $base_url = "/rs/" . rawurlencode($keyword) . "?";
            $pagination = pagination($total, $page_size, $page, $base_url);
        } else {
            $articles = [];
            $total = 0;
            $pagination = '';
            $search_result = ['keywords' => []];
        }
        $seo = get_seo('search', ['keyword' => $keyword_display]);
        include $template_path . 'header.php';
        include $template_path . 'category.php';
        include $template_path . 'footer.php';
        return true;
    }
    
    if ($action === 'list') {
        $page = isset($_GET['page']) ? max(1, intval($_GET['page'])) : 1;
        $page_size = 20;
        
        $total = get_article_count();
        $offset = ($page - 1) * $page_size;
        $articles = get_articles('', "$offset, $page_size");
        $base_url = "/list.html?";
        $pagination = pagination($total, $page_size, $page, $base_url);
        
        $seo = get_seo('category', ['category_name' => '全部文章']);
        
        include $template_path . 'header.php';
        include $template_path . 'category.php';
        include $template_path . 'footer.php';
        return true;
    }
    
    if ($action === 'category') {
        $category_id = isset($_GET['id']) ? intval($_GET['id']) : 0;
        $page = isset($_GET['page']) ? max(1, intval($_GET['page'])) : 1;
        $page_size = 20;
        
        $category_name = '';
        $categories = get_categories();
        foreach ($categories as $cat) {
            if ($cat['id'] == $category_id) {
                $category_name = $cat['name'];
                break;
            }
        }
        if (!$category_name) {
            http_response_code(404);
            require_once ROOT_PATH . '/set/404.php';
            exit;
        }
        
        $seo = get_seo('category', ['category_name' => $category_name]);
        
        $where = "category_id = $category_id";
        $total = get_article_count($where);
        $offset = ($page - 1) * $page_size;
        $articles = get_articles($where, "$offset, $page_size");
        $base_url = "/" . ($setting['category_prefix'] ?? 'category-') . build_url_id('category', $category_id) . ".html?";
        $pagination = pagination($total, $page_size, $page, $base_url);
        
        include $template_path . 'header.php';
        include $template_path . 'category.php';
        include $template_path . 'footer.php';
        return true;
    }
    
    if ($action === 'article') {
        $id = isset($_GET['id']) ? intval($_GET['id']) : 0;
        $article = get_article($id);
        if (!$article) {
            http_response_code(404);
            require_once ROOT_PATH . '/set/404.php';
            exit;
        }
        update_views($id);
        
        $category_name = '';
        $categories = get_categories();
        foreach ($categories as $cat) {
            if ($cat['id'] == $article['category_id']) {
                $category_name = $cat['name'];
                break;
            }
        }
        
        $seo = get_seo('article', [
            'article_title' => $article['title'],
            'article_description' => $article['description'] ?: mb_substr(strip_tags($article['content']), 0, 150),
            'category_name' => $category_name
        ]);
        
        include $template_path . 'header.php';
        include $template_path . 'article.php';
        include $template_path . 'footer.php';
        return true;
    }
    
    if ($action === 'product_list') {
        $category_id = isset($_GET['id']) ? intval($_GET['id']) : 0;
        $page = isset($_GET['page']) ? max(1, intval($_GET['page'])) : 1;
        $page_size = 12;
        
        $category_name = '全部产品';
        if ($category_id > 0) {
            $cats = $db->query("SELECT * FROM {$prefix}product_category ORDER BY sort ASC");
            while ($cat = $cats->fetch_assoc()) {
                if ($cat['id'] == $category_id) {
                    $category_name = $cat['name'];
                    break;
                }
            }
        }
        
        $seo = get_seo('product_list', ['category_name' => $category_name]);
        
        if ($category_id > 0) {
            $where = "WHERE category_id = $category_id";
            $total = $db->query("SELECT COUNT(*) as t FROM {$prefix}product $where")->fetch_assoc()['t'];
        } else {
            $where = '';
            $total = $db->query("SELECT COUNT(*) as t FROM {$prefix}product")->fetch_assoc()['t'];
        }
        
        $offset = ($page - 1) * $page_size;
        $products = $db->query("SELECT * FROM {$prefix}product $where ORDER BY id DESC LIMIT $offset, $page_size");
        $product_cats = $db->query("SELECT * FROM {$prefix}product_category ORDER BY sort ASC");
        
        include $template_path . 'header.php';
        include $template_path . 'product_list.php';
        include $template_path . 'footer.php';
        return true;
    }
    
    if ($action === 'product_detail') {
        $id = isset($_GET['id']) ? intval($_GET['id']) : 0;
        $product = $db->query("SELECT p.*, c.name as category_name FROM {$prefix}product p LEFT JOIN {$prefix}product_category c ON p.category_id = c.id WHERE p.id = $id")->fetch_assoc();
        if (!$product) {
            http_response_code(404);
            require_once ROOT_PATH . '/set/404.php';
            exit;
        }
        $db->query("UPDATE {$prefix}product SET views = views + 1 WHERE id = $id");
        
        $gallery = json_decode($product['gallery'], true);
        if (!is_array($gallery)) $gallery = [];
        
        $seo = get_seo('product_detail', [
            'product_title' => $product['title'],
            'product_description' => $product['description'],
            'category_name' => $product['category_name'] ?? ''
        ]);
        
        include $template_path . 'header.php';
        include $template_path . 'product_detail.php';
        include $template_path . 'footer.php';
        return true;
    }
    
    if ($action === 'index') {
        $seo = get_seo('index');
        $ads = get_ads(5);
        $recommend_articles = get_articles('is_recommend = 1', $seo['recommend_count']);
        $latest_articles = get_articles('', $seo['latest_count']);
        $latest_searches = get_latest_search(5);
        
        include $template_path . 'header.php';
        include $template_path . 'index.php';
        include $template_path . 'footer.php';
        return true;
    }
    
    return false;
}

更新日志

V1.6 修复文章页与栏目页CSS溢出问题 2026-10-19
1、修复文章页与栏目页CSS溢出问题重要提醒:本次修改了:style.css、article.php、category.php 三个文件,若有修改请做好备份。
V1.5 修改联盟ID调用方式 2026-10-08
1、修改联盟ID调用方式2、修改后请测试是否跳转到你自己的联盟ID下,如果没有跳转成功,请联系QQ:2650555588 &nbsp;(因为部分虚拟主机或者宝塔面板没有开放写入权限导致覆盖文件失败)
V1.4 修复wnl的SEO信息 2026-10-06
修复wnl的SEO信息,可直接在模板 header.php 设置。
V1.3 修复万年历页面底部链接 2026-10-05
修复万年历页面底部链接
V1.2 新增自定义导航功能 2026-10-01
1、新增顶部导航后台化设置功能2、新增联盟ID后台设置功能(升级后必须要在后台设置您的ID)3、优化部分细节注意:升级此版本逗号CMS必须为V7.0,否则顶部导航会错误。(如果升级后顶部导航无法打开,删除cache目录下所有文件,他们是旧缓存)特别提醒:升级后到后台--网站设置--顶部导航设置,本版本更新较大,为全部文件覆盖,所有有改过模板的,请先做好备份!有无法解决的问题联系QQ:2650555588
V1.1 优化部分代码 2026-09-25
优化部分代码

常见问题

主题截图 1 / 1