黑白配资讯模板 V1.0
主题分类: 博客资讯
演示地址: 暂无演示,查看截图
CMS版本: 最低 V 6.0
主题价格: 免费
发布日期: 2026-09-28 11:50:35
下载安装 下载安装逗号CMS进入后台--主题中心-安装黑白配资讯模板即可。

黑白配资讯模板 主题说明

简介:专为资讯站、博客、情感语录等内容场景打造的极简黑白配主题。经典双栏布局,左侧内容 + 右侧个人信息卡片,轮播图、双推荐图、图文列表层次清晰,阅读全文模式加持,让内容与转化兼得。

主题截图

首页截图
首页截图
分类页截图
分类页截图
文章详情页截图
文章详情页截图

安装方法

  1. 下载逗号CMS → 登录后台 → 主题管理 → 主题列表,找到「黑白配主题模板」主题,点击免费安装。
  2. 进入 后台 → 网站设置 → 顶部导航,配置顶部导航及链接。
  3. 进入 后台 → 网站设置 → 参数设置,配置首页、分类页、文章页的文章显示数量。
  4. 进入网站设置 → SEO 设置,配置首页、文章分类列表页、文章详情页的 SEO 信息。

配置 API

重要提醒:本主题为资讯类展示型主题,主题本身不依赖任何第三方 API,安装后即可直接使用。所有内容由后台文章、分类、广告、友情链接等模块统一管理。
只有在使用AI自动撰文来生成文章,才需要在逗号API网站有充足积分。(1分钱1篇/千字)

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

功能特色

经典双栏布局

左侧内容区 + 右侧信息卡,PC 端体验舒适,层次清晰。

移动端智能重排

≤1024px 时个人信息卡片自动提到顶部,方便访客联系站长。

轮播 + 双推荐图

顶部轮播图 + 下方 2 张推荐图,视觉层次丰富。

站长信息卡

QQ / 微信(悬停显示二维码)/ 邮箱 / 工作时间 / 电话 / 地址。

阅读全文模式

文章页支持朦胧遮罩 + 阅读全文按钮 + 广告弹窗倒计时。

参数全后台可控

所有列表数量自动读取「网站设置 → 参数设置」,无需改代码。

分词搜索 + 高亮

搜索框跳转 /rs/{关键词},结果标题关键词高亮。

广告位智能判断

后台没配置广告时,不输出容器,不会留下空白区域。

页面列表

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

文件名页面说明URL
header.php公共头部(导航 + SEO + 搜索)-
footer.php公共底部(含备案 + 第三方JS)-
index.php网站首页(轮播 + 双推荐图 + 图文列表 + 信息卡)/
article.php文章详情页(含阅读全文 + 上下篇 + 相关文章)/article-x.html
category.php分类列表页 / 搜索页/list.html、/category-x.html、/rs/关键词
search_rs.php热搜标签聚合页/rs

其他资源

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

广告位配置

黑白配主题调用以下系统广告位:

首页顶部轮播图

调用 banner 广告位(后台「广告管理 → 网站轮播图」):

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

全站顶部横幅

所有页面顶部调用 header_banner 广告位(后台「广告管理 → 网站横幅」):

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

文章页阅读全文广告

文章页点击「阅读全文」时弹出的广告位 article_readmore:

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

底部悬浮广告

调用 footer_float 广告位:

<?php echo get_ad_position('footer_float'); ?>
本主题所有广告位都遵循「有内容才显示,无内容连容器一起隐藏」原则。如果后台没配置对应广告,页面不会留下空白区域。

发布说明

V1.0.0 (2026-09-23)

  • 首次发布
  • 经典双栏布局(左内容 + 右信息卡)
  • 首页顶部轮播图 + 双推荐图 + 图文列表 + 站长信息卡
  • 站长信息卡包含 QQ / 微信(悬停二维码)/ 邮箱 / 工作时间 / 电话 / 地址
  • 右侧热门文章 + 搜索标签(带更多)+ 友情链接
  • 文章详情页支持阅读全文模式 + 阅读全文广告弹窗倒计时
  • 文章页下方上一篇下一篇 + 相关文章
  • 分类列表页 / 搜索页复用 category.php,搜索结果标题高亮
  • 独立热搜标签聚合页 /rs,标签云展示
  • 移动端(≤1024px)自动重排顺序,站长信息卡提至顶部
  • 所有广告位遵循「有内容才输出容器」原则
  • 所有列表数量自动读取「网站设置 → 参数设置」
  • 复用系统默认前端路由,无需自定义路由

前端路由规则

<?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.1 新增搜索标签功能 2026-09-30
1、新增搜索标签功能2、新增顶部导航后台化设置功能3、优化部分细节注意:升级此版本逗号CMS必须为V7.0,否则顶部导航会错误。特别提醒:升级后到后台--网站设置--顶部导航设置,本版本更新较大,为全部文件覆盖,所有有改过模板的,请先做好备份!

常见问题

主题截图 1 / 1