宝宝起名主题模板 主题说明
简介:宝宝起名主题风格大气典雅,以红白为主色调,包含宝宝起名、姓名打分、老黄历查询等。由程序员和专业姓名学老师根据用户输入生辰八字真实排盘开发,速度快,结果好。
主题概览
宝宝起名主题是一款专为起名类网站设计的逗号CMS模板,风格大气典雅,以红白为主色调,适合宝宝起名、姓名打分、老黄历查询等场景,并集成了文章展示模块。内容调用 逗号API接口,该接口由程序员配合专业姓名学老师根据用户真实输入的姓氏及生辰八字排盘计算开发完成,速度快,结果好。
主题截图
安装方法
- 下载逗号CMS → 登录后台 → 主题管理 → 主题列表,找到「宝宝起名主题模板」主题,点击免费安装
- 进入后台 → 网站设置 → SEO 设置,配置首页、文章分类列表页、文章详情页的 SEO 信息。可选:打开模板/templates/jiri/header.php,修改配置各页面的 SEO 信息。
- 进入 后台 → 网站设置 → 顶部导航,配置顶部导航及链接。
- 进入后台 → 网站设置,设置联盟ID。改为你自己在伍柒联盟union.632757.com的ID(右上角),所有收益就像归于您自己名下。【必须是V7.0以上】
- 起名数量:打开模板 /templates/qiming/qiming.php:35行左右
$limit = 500; $per_page = 10;改为您想要的数量。limit 是总结果数,最大500个,per_page 为每页数量。 - 显示403:复制下面前端路由规则代码到:后台 → 管理 → 前端路由管理 → 全选覆盖路由规则 → 保存配置即可
- 测试显示访问受限:后台 → 统计安全 → 安全设置 → 关闭SQL注入。仅9月27日前下载的V6.9版本的部分IIS有此问题,若你遇到此问题未成功解决可以联系QQ:26505555588 反馈。
SEO修改位置
本主题的 SEO 分为两类:一类在后台可视化修改(首页、文章列表页、文章详情页、搜索页、产品页等),另一类需要修改模板文件 header.php(起名结果页、姓名打分页、老黄历页)。请对照下表定位。
一、后台可视化修改(推荐)
路径:后台 → 系统管理 → 网站设置 → SEO 设置,切换到对应 Tab 修改保存即可。
| 页面 | SEO 设置 Tab | URL | 支持的标签 |
|---|---|---|---|
| 首页(起名表单页) | 首页 | / |
{site_name} |
| 文章列表页(全部文章) | 文章分类列表页 | /list.html |
{category_name}、{site_name} |
| 文章分类页 | 文章分类列表页 | /category-x.html |
{category_name}、{site_name} |
| 文章详情页 | 文章详情页 | /article-x.html |
{article_title}、{article_description}、{category_name}、{site_name} |
| 搜索页 | 搜索页 | /rs/关键词 |
{keyword}、{site_name} |
| 热搜标签聚合页 | 热搜标签聚合页 | /rs |
{site_name} |
| 产品列表页 / 产品分类页 | 产品分类页 | /product.html |
{category_name}、{site_name} |
| 产品详情页 | 产品详情页 | /product-x.html |
{product_title}、{product_description}、{site_name} |
二、header.php 中修改(起名 / 打分 / 老黄历)
起名结果页、姓名打分页、老黄历页三个页面的 SEO 是写在模板文件 /templates/qiming/header.php 里的,需要打开该文件,找到顶部对应的 $seo 数组,修改 title、keywords、description 三项后保存。
| 页面 | URL | 修改位置 |
|---|---|---|
| 起名结果页 | /qiming.html |
header.php 中 $current_uri === '/qiming.html' 分支下的 $seo 数组 |
| 姓名打分页 | /dafen.html、/dafen/姓名 |
header.php 中 $current_uri === '/dafen.html' || strpos($current_uri, '/dafen/') === 0 分支下的 $seo 数组 |
| 老黄历页 | /laohuangli.html |
header.php 中 $current_uri === '/laohuangli.html' 分支下的 $seo 数组 |
修改示例
例如要修改「宝宝起名结果页」的 SEO,打开 /templates/qiming/header.php,找到这一段:
if ($current_uri === '/qiming.html') {
$surname = '';
if (!empty($_POST['surname'])) {
$surname = trim($_POST['surname']);
} elseif (!empty($_GET['surname'])) {
$surname = trim($_GET['surname']);
}
$title_prefix = $surname !== '' ? $surname . '姓氏宝宝起名八字起名结果' : '宝宝起名八字起名结果';
$seo = [
'title' => $title_prefix . ' - ' . $setting['site_name'],
'keywords' => '宝宝起名,八字起名,周易起名,起名推荐,好名字大全',
'description' => '基于八字五行、音律字形、国学经典,为宝宝生成吉祥好名。'
];
}
把 title、keywords、description 三个值改成自己想要的即可,保存后立即生效。
三、其他 SEO 位置
- 网站名称:后台 → 系统管理 → 网站设置 → 网站名称(影响所有页面的
{site_name}变量) - 网站 LOGO:后台 → 系统管理 → 网站设置 → 网站LOGO
- ICP 备案号:后台 → 系统管理 → 网站设置 → ICP备案号(显示在页面底部)
- 首页/内页 SEO 数据结构:由模板
/templates/qiming/header.php决定,一般不需要改动
/templates/qiming/header.php 里修改 $seo 数组。功能特色
八字智能起名
输入姓氏、出生日期和性别,基于八字五行自动计算出吉祥好名,并附带诗词出处。
姓名综合打分
从五格数理、三才配置、八字五行等多维度为姓名综合评分,输出完整分析报告。
老黄历查询
查询每日黄历,包含宜忌、吉神凶煞、值神、星宿、时辰吉凶等详细信息。
PC/手机自适应
一套模板自动适配各种屏幕尺寸,手机端起名用字信息纵向排列,阅读更舒适。
红金典雅配色
中国红主色调,搭配楷体"名/福"等大背景字,传统与现代结合的视觉体验。
广告位支持
顶部横幅广告位,可在后台「广告管理 → 网站横幅」中配置图片/代码/文字广告。
热搜标签系统
用户搜索词自动入库,支持聚合页展示、热搜排行榜、标题关键词高亮。
自带收益转化
对接伍柒联盟,专业起名按钮直接跳转,只需修改ID,收益直接进您账户。
配置 API
宝宝起名依赖「逗号API」接口,各功能接口如下:
核心功能接口
- 宝宝起名 — 输入姓氏、出生日期和性别,基于八字五行自动计算出吉祥好名
调用API接口:https://api.douhao.com/jie/55.html,10积分/次,中级代理免费调用 - 姓名打分 — 输入姓名,从五格数理、三才配置、八字五行等维度综合评分
调用API接口:https://api.douhao.com/jie/22.html,2积分/次,中级代理免费调用 - 老黄历 — 查询每日黄历,包含宜忌、吉神凶煞、时辰吉凶等详细内容
调用API接口:https://api.douhao.com/jie/16.html,1积分/次,初级代理免费调用
获取 API 密钥
- 访问
逗号API网站注册账号 - 登录后台首页,复制「API密钥」
配置 API 密钥
- 您的网站后台 → 网站设置(或主题中心)
- 在「逗号API密钥」输入框粘贴密钥--保存设置
积分获取方式
接口参数一览
| 功能 | api_id | 入参字段 |
|---|---|---|
| 宝宝起名 | 55 | surname / birthday / birthTime / gender / limit |
| 姓名打分 | 22 | xs(姓氏)/ mz(名字) |
| 老黄历 | 16 | date(yyyy-mm-dd) |
页面列表
配置前端路由后,以下页面均可正常访问:
| 页面 | URL | 说明 |
|---|---|---|
| 首页 | / |
起名主题首页 |
| 宝宝起名 | /qiming.html |
起名表单及结果页 |
| 姓名打分 | /dafen.html |
姓名综合评分 |
| 老黄历 | /laohuangli.html |
每日黄历查询 |
| 全部文章 | /list.html |
文章列表 |
| 文章分类 | /category-{id}.html |
分类文章列表 |
| 文章详情 | /article-{id}.html |
文章内容详情 |
前端路由规则
<?php
function parse_rewrite_url($uri, $setting, $db, $prefix) {
if ($uri === "/" || $uri === "/index.php") {
return "qiming_index";
}
if ($uri === "/qiming.html") {
return "qiming_result";
}
if ($uri === "/dafen.html") {
return "qiming_dafen";
}
if ($uri === "/laohuangli.html") {
return "qiming_laohuangli";
}
$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 __DIR__ . "/set/404.php";
exit;
}
$stmt->close();
} else {
http_response_code(404);
require_once __DIR__ . "/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 __DIR__ . "/set/404.php";
exit;
}
$stmt->close();
} else {
http_response_code(404);
require_once __DIR__ . "/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 __DIR__ . "/set/404.php";
exit;
}
$stmt->close();
} else {
http_response_code(404);
require_once __DIR__ . "/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 __DIR__ . "/set/404.php";
exit;
}
$stmt->close();
} else {
http_response_code(404);
require_once __DIR__ . "/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";
}
return "index";
}
function route_dispatch($action, $db, $prefix, $setting, $template_path) {
if ($action === "qiming_index") {
if (!isset($_GET["year"]) || !isset($_GET["month"])) {
$_GET["year"] = date("Y");
$_GET["month"] = date("n");
}
$year = intval($_GET["year"]);
$month = intval($_GET["month"]);
if ($month < 1) $month = 1;
if ($month > 12) $month = 12;
$_GET["year"] = $year;
$_GET["month"] = $month;
$seo = [
"title" => "宝宝起名 - " . $setting["site_name"],
"keywords" => "宝宝起名,取名,八字起名",
"description" => "基于八字五行、音律字形、国学经典,为宝宝起个好名"
];
include ROOT_PATH . "templates/qiming/header.php";
include ROOT_PATH . "templates/qiming/index.php";
include ROOT_PATH . "templates/qiming/footer.php";
return true;
}
if ($action === "qiming_result") {
$seo = [
"title" => "宝宝起名结果 - " . $setting["site_name"],
"keywords" => "宝宝起名,八字起名,周易起名,起名推荐",
"description" => "基于八字五行、音律字形、国学经典,为宝宝生成吉祥好名"
];
include ROOT_PATH . "templates/qiming/header.php";
include ROOT_PATH . "templates/qiming/qiming.php";
include ROOT_PATH . "templates/qiming/footer.php";
return true;
}
if ($action === "qiming_dafen") {
$seo = [
"title" => "姓名打分 - " . $setting["site_name"],
"keywords" => "姓名打分,名字评分,五格数理,三才配置",
"description" => "基于五格数理、三才配置、八字五行,为姓名综合评分"
];
include ROOT_PATH . "templates/qiming/header.php";
include ROOT_PATH . "templates/qiming/dafen.php";
include ROOT_PATH . "templates/qiming/footer.php";
return true;
}
if ($action === "qiming_laohuangli") {
$seo = [
"title" => "老黄历 - " . $setting["site_name"],
"keywords" => "老黄历,黄道吉日,择日,万年历,黄历查询",
"description" => "提供每日黄历查询,包含宜忌、吉神凶煞、时辰吉凶等"
];
include ROOT_PATH . "templates/qiming/header.php";
include ROOT_PATH . "templates/qiming/laohuangli.php";
include ROOT_PATH . "templates/qiming/footer.php";
return true;
}
if ($action === "search") {
$keyword = isset($_GET["keyword"]) ? trim($_GET["keyword"]) : "";
if (!empty($keyword)) {
if (!check_sensitive_words($keyword)) die("搜索内容包含敏感词");
$keyword = str_replace(["%", "_"], ["\\%", "\\_"], $keyword);
save_search_keyword($keyword);
$articles = get_articles("title LIKE \"%" . $db->real_escape_string($keyword) . "%\"", 50);
} else {
$articles = [];
}
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 __DIR__ . "/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 __DIR__ . "/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 __DIR__ . "/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