青涩时光主题模板 V1.1
主题分类: 知识文案
演示地址: 暂无演示,查看截图
CMS版本: 最低 V 6.9
主题价格: 免费
发布日期: 2026-09-28 11:50:35
下载安装 下载安装逗号CMS进入后台--主题中心-安装青涩时光主题模板即可。

青涩时光主题模板 主题说明

简介:青涩时光是一款由极光渐变背景 + 液态玻璃质感构成,为个人博客、内容站打造的现代化响应式主题。支持精选推荐、分类导航、最新文章、热门排行、友情链接,PC / 手机端自动适配,一套模板即可开箱使用。

主题截图

首页截图
首页截图
文章详情页截图
文章详情页截图
分类页截图
分类页截图
用户投稿页面截图
用户投稿页面截图
后台首页
后台首页
后台统计安全页
后台统计安全页

安装方法

  • 下载逗号CMS → 登录后台 → 主题管理 → 主题列表,找到「青涩时光主题模板」主题,点击免费安装。
  • 必看 文章数量调整 / 留言本管理 / 热搜标签管理
    1. 后台 → 系统管理 → 网站设置 → 参数设置
    2. 后台 → 留言管理 → 添加用户投稿等需要的留言页面(不要留言本请打开文件 templates/shiguang/header.php 删除留言本链接即可)
    3. 后台 → 搜索标签 → 添加或发布搜索词

    主题特色

    极光渐变背景

    多层径向渐变叠加,蓝紫粉青渐次晕染,视觉现代且有层次感。

    液态玻璃质感

    所有卡片采用 backdrop-filter 毛玻璃效果,边角高光模拟玻璃质感。

    精选推荐布局

    左侧大图 + 右侧 4 张小图的杂志式布局,只展示有图片的文章。

    分类导航卡片

    按分类 ID 倒序展示,每个分类卡片显示对应文章数量。

    最新文章列表

    左图右文的横向卡片布局,展示文章标题、摘要、阅读量、发布时间。

    侧边栏模块

    热门文章排行榜(带名次标签)+ 友情链接胶囊标签。

    PC / 手机自适应

    一套模板自动适配,手机端抽屉式导航菜单,交互体验佳。

    全屏搜索弹层

    点击搜索图标弹出居中搜索框,支持 ESC 关闭。

    页面列表

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

    文件名页面说明URL
    header.php公共头部(导航 + 搜索)-
    footer.php公共底部(分类导航 + 返回顶部)-
    index.php网站首页/
    category.php文章分类列表页/list.html、/category-x.html
    article.php文章详情页/article-x.html

    其他资源

    文件说明
    /templates/shiguang/style.css主题全局样式

    首页包含的模块

    模块数据来源数量配置
    精选推荐标记为「推荐」且有图片的文章参数设置 → 首页推荐文章数
    分类导航后台所有文章分类(按 ID 倒序)自动
    最新文章最新发布的文章参数设置 → 首页最新文章数
    热门文章标记为「热门」的文章(按阅读量倒序)参数设置 → 首页热门文章数
    友情链接后台友情链接(启用状态)最多 20 个

    广告位配置

    青涩时光主题支持通过 CMS 广告位功能在页面中插入广告。

    如何在模板中调用广告位?

    在模板文件(如 header.php、index.php)中插入以下代码即可:

    <?php echo get_ad_position('header_banner'); ?>

    其中 header_banner 是广告位标识,可替换为后台创建的其他广告位标识。

    如何配置顶部横幅广告?

    1. 后台 → 内容管理 → 广告管理 → 广告位管理
    2. 找到「网站横幅」广告位,点击「广告设置」
    3. 点击「添加广告」,填写标题、选择投放页面
    4. 选择广告模板(图片 / 代码 / 文字)
    5. 设置排序、状态(启用),保存

    如何让广告只在首页显示?

    在广告编辑页面,将「投放页面」只勾选「首页」即可。若想全站展示,勾选「不限页面」。

    如需在主题的其他位置(如文章页顶部、侧边栏)插入广告,可在对应模板文件中调用 get_ad_position('广告位标识')。

    更新日志

    V1.2 新增导航自定义功能 2026-10-01
    1、新增顶部导航后台化设置功能2、优化部分细节注意:升级此版本逗号CMS必须为V7.0,否则顶部导航会错误。特别提醒:升级后到后台--网站设置--顶部导航设置,本版本更新较大,为全部文件覆盖,所有有改过模板的,请先做好备份!
    V1.1 增加搜索标签等功能 2026-09-28
    1、增加搜索标签;2、注意:此次更新会覆盖所有页面,自行修改过页面的不要更新!

    前端路由规则

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

    常见问题

    主题截图 1 / 1