万年历主题模板 主题说明
简介:专为"万年历 / 老黄历"场景打造的响应式主题,涵盖黄历日历、黄道吉日、放假安排、节日表、24节气、老黄历详情等场景,对接逗号API实时拉取黄历数据。
主题概览
「万年历主题模板」是逗号CMS官方推出的一款行业主题,专为万年历、老黄历类网站设计。主题内含 黄历日历首页、黄道吉日大全、黄道吉日详情、放假安排、节日表、24节气表、老黄历日期详情、文章分类、文章详情 等页面,整站采用中国红 + 富贵金的喜庆配色,结合传统书法字体背景装饰,营造传统择吉文化的厚重感。
主题截图
安装方法
- 下载逗号CMS → 登录后台 → 主题管理 → 主题列表,找到「万年历主题模板」主题,点击免费安装
- 进入后台 → 网站设置 → SEO 设置,配置首页、文章分类列表页、文章详情页的 SEO 信息。可选:打开模板/templates/jiri/header.php,修改配置各页面的 SEO 信息。
- 进入 后台 → 网站设置 → 顶部导航,配置顶部导航及链接。
- 进入后台 → 网站设置,设置联盟ID。改为你自己在伍柒联盟union.632757.com的ID(右上角),所有黄道吉日中付费项目收益就像归于您自己名下。【说明:不要此付费项目功能,自行到hdjr_detail.php删除即可】
- 显示403:复制下面前端路由规则代码到:后台 → 管理 → 前端路由管理 → 全选覆盖路由规则 → 保存配置即可
- 万年历依赖API,如果发现没有出数据:登录逗号API后台 → 查看顶部积分是否充足,积分不足充值积分或者加盟代理即可。
配置 API
万年历依赖「逗号API」接口老黄历日历详版 :https://api.douhao.com/jie/16.html
这个老黄历是只要出结果就是调用,所以初始安装没有缓存调用会比较频繁,每次调用将消耗1积分(注册有赠送50积分),不过我们每个日期系统都自动缓存,头几天调用消耗可能比较快,后续就很少了。所以不要觉得消耗快用不起。
建议:199元/年初级代理就可以每天免费1万次。,新站包你够用,超出全免。
代理权益列表:https://api.douhao.com/daili 。
获取 API 密钥
- 访问
逗号API网站注册账号 - 登录后台首页,复制「API密钥」
配置 API 密钥
- 您的网站后台 → 网站设置(或主题中心)
- 在「逗号API密钥」输入框粘贴密钥--保存设置
接口参数一览
| API接口 | api_id | API接口网址 |
|---|---|---|
| 老黄历日历详情 | 16 | https://api.douhao.com/jie/16.html |
| 老黄历吉日查询 | 69 | https://api.douhao.com/jie/69.html |
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'] |
| 黄道吉日首页 | /hdjr | header.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设置 → 搜索页(当前模板未单独接) |
| 热搜标签聚合 | /rs | header.php 自动 | 后台 → 网站设置 → SEO设置 → 搜索聚合页(当前模板未单独接) |
最常用的修改位置速查
| 改哪个 | 去哪里改 |
|---|---|
| 首页标题关键词描述 | 后台 SEO设置 → 首页 |
| 文章详情页标题模板 | 后台 SEO设置 → 文章详情页 |
| 分类页标题模板 | 后台 SEO设置 → 文章分类页 |
| 日期详情页 SEO | templates/wnl/day.php 里的 $GLOBALS['wnl_seo'] |
| 吉日详情 SEO | templates/wnl/hdjr_detail.php 里的 $GLOBALS['wnl_seo'] |
| 放假安排 SEO | templates/wnl/jiaqi.php 里的 $GLOBALS['wnl_seo'] |
| 节日表 SEO | templates/wnl/jieri.php 里的 $GLOBALS['wnl_seo'] |
| 24节气 SEO | templates/wnl/jieqi.php 里的 $GLOBALS['wnl_seo'] |
| 黄道吉日首页 SEO | templates/wnl/header.php 里的 $wnl_static_seo['hdjr'] |
可用标签变量
在 $GLOBALS['wnl_seo'] 里可以直接写 {site_name}(自动替换成网站名称)。部分页面还预设了额外的变量:
| 变量 | 适用页面 | 含义 |
|---|---|---|
{site_name} | 所有页面 | 网站名称 |
$hl_solar_str | day.php | 公历字符串(如 2026年8月31日) |
$hl_lunar_str | day.php | 农历字符串(如 七月初八) |
$hl_ganzhi_str | day.php | 干支字符串(如 丙午年 丙申月 戊申日) |
$query_year | hdjr_detail.php、jiaqi.php、jieri.php、jieqi.php | 年份(如 2026) |
$slug | hdjr_detail.php | 吉日类型(如 结婚、开业) |
/cache/front_route_cache.php 和浏览器缓存(Ctrl+F5)。若开启了页面静态缓存,还需到「缓存管理」清空对应类型缓存。功能特色
月度黄历日历
首页展示月度日历,每个日期同时显示公历、农历、节气、节日、休班标记,鼠标悬停日期直达详情。
黄道吉日大全
汇集嫁娶、开市、动土、入宅、出行、祭祀等数十种黄道吉日分类,可跳转各类型吉日详情。
吉日详情页
展示全年该吉日类型的所有可用日期,含农历、干支、值神、建除十二神、二十八星宿等完整信息。
放假安排
展示全年的法定节假日放假及调休安排,含节日标签,点击日期直达老黄历详情。
节日表
完整收录全年阳历、农历节日,含元旦、春节、清明、中秋、国庆等重大节日与各类纪念日。
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.php | 24节气表 | /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'); ?>
如何配置顶部横幅广告?
- 后台 → 内容管理 → 广告管理
- 找到 「网站横幅」 广告位,点击「广告设置」
- 点击「添加广告」,填写标题、选择投放页面(首页/分类页/文章详情/产品分类/产品详情)
- 选择广告模板(图片/代码/文字)
- 设置排序、状态(启用),保存
前端路由规则
<?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;
}
逗号CMS