| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- <?php
- // 引入公共查询类
- require_once 'CommonQuery.php';
- // 获取URL参数
- $channel = isset($_GET['channel']) ? $_GET['channel'] : '党建工作';
- $currentPage = isset($_GET['page']) ? intval($_GET['page']) : 1;
- if ($currentPage < 1) {
- $currentPage = 1;
- }
- // 每页显示的文章数量
- $pageSize = 10;
- // 使用loadListByChannelNameAndPage函数查询数据
- $result = loadListByChannelNameAndPage($pageSize, $channel, $currentPage);
- $partyBuilding = $result['list'] ?? [];
- $totalPages = $result['totalPages'] ?? 0;
- // 如果总页数小于当前页,则调整当前页
- if ($totalPages > 0 && $currentPage > $totalPages) {
- $currentPage = $totalPages;
- // 重新查询当前页数据
- $result = loadListByChannelNameAndPage($pageSize, $channel, $currentPage);
- $partyBuilding = $result['list'] ?? [];
- }
- // 轮播图数据 - 修改为单张图片
- $carouselItems = [
- [
- "image" => "/images/test-header-2.png",
- "alt" => $channel
- ]
- ];
- ?>
- <!DOCTYPE html>
- <html lang="zh-CN">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>厦门市文化遗产保护中心 - 党建工作</title>
- <link rel="stylesheet" href="/css/fonts.css">
- <link rel="stylesheet" href="/css/fontawesome.min.css">
- <link rel="stylesheet" href="/css/bootstrap.min.css">
- <link rel="stylesheet" href="/css/swiper-bundle.min.css">
- <link rel="stylesheet" href="/css/style.css">
- <script src="/js/jquery-3.7.1.js"></script>
- <script src="/js/bootstrap.bundle.js"></script>
- <script src="/js/swiper-bundle.min.js"></script>
- </head>
- <body>
- <?php include __DIR__ . '/components/navbar.php'; ?>
- <!-- 轮播图 -->
- <div class="swiper mySwiper" style="width: 100%; height: 400px;">
- <div class="swiper-wrapper">
- <?php foreach ($carouselItems as $item): ?>
- <div class="swiper-slide">
- <img src="<?php echo $item['image']; ?>" alt="<?php echo $item['alt']; ?>" style="width: 100%; height: 100%; object-fit: cover;">
- </div>
- <?php endforeach; ?>
- </div>
- <div class="swiper-pagination"></div>
- <div class="swiper-button-prev"></div>
- <div class="swiper-button-next"></div>
- </div>
- <!-- 主要内容 -->
- <div class="main-content">
- <div class="container">
- <div class="row">
- <!-- 左侧导航 -->
- <div class="col col-sm-12 col-md-3 col-lg-3">
- <div class="sidebar">
- <div class="title">
- <h2><?php echo $channel; ?></h2>
- </div>
- <ul class="sidebar-menu">
- <li><a href="?channel=党建工作">党建工作<i class="fa fa-arrow-right"></i></a></li>
- <li><a href="?channel=党建要闻">党建要闻<i class="fa fa-arrow-right"></i></a></li>
- </ul>
- </div>
- </div>
-
- <!-- 右侧内容 -->
- <div class="col col-sm-12 col-md-9 col-lg-9">
- <div class="content">
- <div class="section-title">
- <h2 class="icon"><?php echo $channel; ?></h2>
-
- <nav aria-label="breadcrumb">
- <ol class="breadcrumb">
- <li class="breadcrumb-item"><a href="/">首页</a></li>
- <li class="breadcrumb-item active" aria-current="page"><?php echo $channel; ?></li>
- </ol>
- </nav>
- </div>
-
- <!-- 文章列表 -->
- <div class="news-list">
- <?php if (!empty($partyBuilding)): ?>
- <?php foreach ($partyBuilding as $item): ?>
- <div class="news-item">
- <!-- 使用id作为文章详情页的参数,标题和日期字段可能需要根据实际数据库结构调整 -->
- <a href="/xinWenXiangQing.php?id=<?php echo isset($item['id']) ? $item['id'] : $item['title']; ?>" class="title">
- <?php echo isset($item['title']) ? $item['title'] : (isset($item['subject']) ? $item['subject'] : ''); ?>
- </a>
- <span class="date">
- <?php echo date('Y-m-d', strtotime($item['createtime'])) ?>
- </span>
- </div>
- <?php endforeach; ?>
- <?php else: ?>
- <div class="no-news">暂无数据</div>
- <?php endif; ?>
- </div>
-
- <!-- 分页 -->
- <nav aria-label="List Page navigation">
- <ul class="pagination mt-4">
- <?php if ($totalPages > 0): ?>
- <?php for ($i = 1; $i <= $totalPages; $i++): ?>
- <li class="<?php echo $i == $currentPage ? 'active' : ''; ?>">
- <a href="?channel=<?php echo urlencode($channel); ?>&page=<?php echo $i; ?>">
- <?php echo $i; ?>
- </a>
- </li>
- <?php endfor; ?>
- <?php endif; ?>
- </ul>
- </nav>
- </div>
- </div>
- </div>
- </div>
- </div>
- <?php include __DIR__ . '/components/footer.php'; ?>
-
- <script>
- $(document).ready(function() {
- // 初始化 Swiper
- const swiper = new Swiper(".mySwiper", {
- slidesPerView: 1,
- spaceBetween: 30,
- loop: true,
- pagination: {
- el: ".swiper-pagination",
- clickable: true,
- },
- navigation: {
- nextEl: ".swiper-button-next",
- prevEl: ".swiper-button-prev",
- },
- autoplay: {
- delay: 5000,
- disableOnInteraction: false,
- },
- });
- });
- </script>
- </body>
- </html>
|