星座运势主题模板 V1.2
主题分类: 传统文化
CMS版本: 最低 V 7.0
主题价格: 免费
发布日期: 2026-10-13 11:09:56
下载安装 提示:下载为默认主题,必须登后台--主题中心--安装星座运势主题模板方可。

星座运势主题模板 主题说明

简介:专为星座、运势、占星类网站设计。主题内含 十二星座运势查询、圆环评分可视化、幸运信息展示 三大核心功能,整站采用星象紫 + 梦幻渐变的配色方案,配合旋转星座轮盘,营造神秘的占星氛围。

主题截图

首页截图
首页截图
文章详情页截图
文章详情页截图
分类页截图
分类页截图
移动端首页
移动端首页
移动端分类页
移动端分类页
移动端文章页
移动端文章页

安装方法

  1. 下载逗号CMS → 登录后台 → 主题管理 → 主题列表,找到「兴趣圈子主题模板」主题,点击免费安装。
  2. 进入 后台 → 网站设置 → 顶部导航,配置顶部导航及链接(已内置,建议不修改只增加)。
  3. 进入 后台 → 网站设置 → 参数设置,配置首页、分类页、文章页的文章显示数量。
  4. 进入网站设置 → SEO 设置,配置首页、文章分类列表页、文章详情页的 SEO 信息。
  5. 可选:我们在img文件夹自带了所有星座图片,全部为原创图片,您可以更换,也可以保持不变。

功能特色

十二星座运势

覆盖白羊到双鱼全部 12 星座,点击任意星座即可查询运势,支持今日/明日/本周/本月/本年五种周期。

圆环评分可视化

综合、爱情、工作、财运、健康五项评分以圆环动画呈现,一目了然看清各项运势强弱。

幸运信息卡片

速配星座、幸运色、幸运数字以卡片形式展示,PC端3张、移动端4张(含综合评分),排列整齐美观。

星座轮盘动画

首页 Hero 区配备旋转的星座轮盘,12 星座符号围绕中心缓缓旋转,营造神秘的占星氛围。

分类页自动带运势

分类名称为 12 星座名称时,分类页顶部自动显示该星座运势卡片,其他分类不显示,精准匹配场景。

PC / 手机自适应

一套模板自动适配各种屏幕尺寸。移动端自动隐藏 Hero、简化导航为横向滑动、优化评分布局。

星象紫渐变配色

主色调 #A78BFA 到 #7C3AED 的紫系渐变,配合背景网格纹理和星座符号装饰,梦幻典雅。

全广告位支持

支持顶部横幅、网站轮播、底部悬浮、文章页阅读全文共 4 个系统广告位,与默认模板一致。

热搜标签系统

用户搜索词自动入库,首页底部展示搜索标签,支持热搜聚合页,标题关键词自动高亮。

API分词搜索

优先调用逗号API分词接口,未返回数据时自动回退到系统分词,让搜索结果更精准。

顶部导航后台化

导航菜单完全由后台「顶部导航」控制,支持内部链接和外部链接,URL 跟随伪静态设置自动生成。

安全与缓存

支持 CSRF 防护、XSS 过滤、SQL 注入检测;与默认模板一样支持页面静态缓存,访问飞快。

配置 API

星座运势主题依赖「逗号API」的星座运势接口提供数据,本主题只调用一个接口,配置非常简单。

核心功能接口

获取 API 密钥

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

配置 API 密钥

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

积分获取方式

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

接口参数一览

参数名类型必填说明
cidinteger是星座 ID,范围 1~12
typestring否运势类型:today / tomorrow / week / month / year
formatstring否返回格式:json(默认)或 txt

星座 ID 对照表

ID星座ID星座ID星座
1白羊座5狮子座9射手座
2金牛座6处女座10摩羯座
3双子座7天秤座11水瓶座
4巨蟹座8天蝎座12双鱼座
本主题的 api.php 已内置 当天结果缓存(PC 与移动端共用同一份缓存),同一星座同一运势一天内重复访问不会消耗积分。逗号API每日登录赠送20积分,所以新站赠送的积分基本上够用了。

页面列表

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

文件名页面说明URL
header.php公共头部(导航 + SEO + 顶部横幅)-
footer.php公共底部(版权 + 悬浮广告 + 返回顶部)-
index.php网站首页(星座轮盘 + 运势查询 + 星座资讯 + 搜索标签)/
category.php分类列表页 / 搜索页(星座分类自动带运势卡片)/list.html、/category-x.html、/rs/关键词
article.php文章详情页(支持阅读全文 + 广告弹窗)/article-x.html
search_rs.php热搜标签聚合页/rs
api.php星座运势 API 转发(含 5 分钟结果缓存)-
style.css主题全局样式-
route.php主题路由文件-
upgrade.php主题安装脚本(自动删除)-

其他资源

文件 / 目录说明
/templates/xingzuo/img/1.jpg ~ 12.jpg12 星座分类图标兜底图(分类未上传图标时使用)

广告位配置

星座运势主题对接了与默认模板一致的 4 个系统广告位:

广告位标识广告位名称调用位置
banner网站轮播图首页、分类页、文章页、热搜聚合页 顶部
header_banner网站横幅所有页面顶部(导航下方)
footer_float网站底部悬浮所有页面底部悬浮
article_readmore文章页阅读全文文章页点击「阅读全文」时弹出的广告

如何配置广告?

  1. 后台 → 内容管理 → 广告管理,进入广告位管理页面
  2. 找到对应广告位,点击「广告设置」
  3. 点击「添加广告」,填写标题、选择投放页面(首页/分类页/文章详情/产品分类/产品详情/不限页面)
  4. 选择广告模板(图片/代码/文字)
  5. 设置排序、状态(启用),保存
首页、分类页顶部的 banner 轮播广告建议上传 1920×500px 的大图,配合星象紫主题效果更佳。

前端路由规则

<?php
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';
        }
    }

    $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 === '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.2 修复部分分辨率的出生地弹窗样式 2026-10-22
1、修复部分分辨率的出生地弹窗样式2、优化其他部分CSS
V1.1 新增联盟对接,增加收益 2026-10-15
1、首页、分类页、文章页都新增联盟对接,增加收益2、优化首页文章列表,改为后台--网站设置--参数设置--首页最新文章来设置。必做:升级后必须到后台--网站设置 中将联盟ID改为您自己的ID,这样收益就到您自己的联盟账户下。
主题截图 1 / 1