dangnJianGongZuo.php 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <?php
  2. // 引入公共查询类
  3. require_once 'CommonQuery.php';
  4. // 获取URL参数
  5. $channel = isset($_GET['channel']) ? $_GET['channel'] : '党建工作';
  6. $currentPage = isset($_GET['page']) ? intval($_GET['page']) : 1;
  7. if ($currentPage < 1) {
  8. $currentPage = 1;
  9. }
  10. // 每页显示的文章数量
  11. $pageSize = 10;
  12. // 使用loadListByChannelNameAndPage函数查询数据
  13. $result = loadListByChannelNameAndPage($pageSize, $channel, $currentPage);
  14. $partyBuilding = $result['list'] ?? [];
  15. $totalPages = $result['totalPages'] ?? 0;
  16. // 如果总页数小于当前页,则调整当前页
  17. if ($totalPages > 0 && $currentPage > $totalPages) {
  18. $currentPage = $totalPages;
  19. // 重新查询当前页数据
  20. $result = loadListByChannelNameAndPage($pageSize, $channel, $currentPage);
  21. $partyBuilding = $result['list'] ?? [];
  22. }
  23. // 轮播图数据 - 修改为单张图片
  24. $carouselItems = [
  25. [
  26. "image" => "/images/test-header-2.png",
  27. "alt" => $channel
  28. ]
  29. ];
  30. ?>
  31. <!DOCTYPE html>
  32. <html lang="zh-CN">
  33. <head>
  34. <meta charset="UTF-8">
  35. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  36. <title>厦门市文化遗产保护中心 - 党建工作</title>
  37. <link rel="stylesheet" href="/css/fonts.css">
  38. <link rel="stylesheet" href="/css/fontawesome.min.css">
  39. <link rel="stylesheet" href="/css/bootstrap.min.css">
  40. <link rel="stylesheet" href="/css/swiper-bundle.min.css">
  41. <link rel="stylesheet" href="/css/style.css">
  42. <script src="/js/jquery-3.7.1.js"></script>
  43. <script src="/js/bootstrap.bundle.js"></script>
  44. <script src="/js/swiper-bundle.min.js"></script>
  45. </head>
  46. <body>
  47. <?php include __DIR__ . '/components/navbar.php'; ?>
  48. <!-- 轮播图 -->
  49. <div class="swiper mySwiper" style="width: 100%; height: 400px;">
  50. <div class="swiper-wrapper">
  51. <?php foreach ($carouselItems as $item): ?>
  52. <div class="swiper-slide">
  53. <img src="<?php echo $item['image']; ?>" alt="<?php echo $item['alt']; ?>" style="width: 100%; height: 100%; object-fit: cover;">
  54. </div>
  55. <?php endforeach; ?>
  56. </div>
  57. <div class="swiper-pagination"></div>
  58. <div class="swiper-button-prev"></div>
  59. <div class="swiper-button-next"></div>
  60. </div>
  61. <!-- 主要内容 -->
  62. <div class="main-content">
  63. <div class="container">
  64. <div class="row">
  65. <!-- 左侧导航 -->
  66. <div class="col-12 col-sm-12 col-md-4 col-lg-3">
  67. <div class="sidebar">
  68. <div class="title">
  69. <h2><?php echo $channel; ?></h2>
  70. </div>
  71. <ul class="sidebar-menu">
  72. <li><a href="https://www.12371.cn/special/xxzd/">学习专栏<i class="fa fa-arrow-right"></i></a></li>
  73. <li><a href="?channel=党建工作">党建工作<i class="fa fa-arrow-right"></i></a></li>
  74. <li><a href="?channel=党建要闻">党建要闻<i class="fa fa-arrow-right"></i></a></li>
  75. </ul>
  76. </div>
  77. </div>
  78. <!-- 右侧内容 -->
  79. <div class="col-12 col-sm-12 col-md-8 col-lg-9">
  80. <div class="content">
  81. <div class="section-title">
  82. <h2 class="icon"><?php echo $channel; ?></h2>
  83. <nav aria-label="breadcrumb">
  84. <ol class="breadcrumb">
  85. <li class="breadcrumb-item"><a href="/">首页</a></li>
  86. <li class="breadcrumb-item active" aria-current="page"><?php echo $channel; ?></li>
  87. </ol>
  88. </nav>
  89. </div>
  90. <!-- 文章列表 -->
  91. <div class="news-list">
  92. <?php if (!empty($partyBuilding)): ?>
  93. <?php foreach ($partyBuilding as $item): ?>
  94. <div class="news-item">
  95. <!-- 使用id作为文章详情页的参数,标题和日期字段可能需要根据实际数据库结构调整 -->
  96. <a href="/xinWenXiangQing/?id=<?php echo isset($item['id']) ? $item['id'] : $item['title']; ?>" class="title">
  97. <?php echo isset($item['title']) ? $item['title'] : (isset($item['subject']) ? $item['subject'] : ''); ?>
  98. </a>
  99. <span class="date">
  100. <?php echo date('Y-m-d', intval($item['createtime'])) ?>
  101. </span>
  102. </div>
  103. <?php endforeach; ?>
  104. <?php else: ?>
  105. <div class="no-news">暂无数据</div>
  106. <?php endif; ?>
  107. </div>
  108. <!-- 分页 -->
  109. <nav aria-label="List Page navigation">
  110. <ul class="pagination mt-4">
  111. <?php if ($totalPages > 0): ?>
  112. <?php for ($i = 1; $i <= $totalPages; $i++): ?>
  113. <li class="<?php echo $i == $currentPage ? 'active' : ''; ?>">
  114. <a href="?channel=<?php echo urlencode($channel); ?>&page=<?php echo $i; ?>">
  115. <?php echo $i; ?>
  116. </a>
  117. </li>
  118. <?php endfor; ?>
  119. <?php endif; ?>
  120. </ul>
  121. </nav>
  122. </div>
  123. </div>
  124. </div>
  125. </div>
  126. </div>
  127. <?php include __DIR__ . '/components/footer.php'; ?>
  128. <script>
  129. $(document).ready(function() {
  130. // 初始化 Swiper
  131. const swiper = new Swiper(".mySwiper", {
  132. slidesPerView: 1,
  133. spaceBetween: 30,
  134. loop: true,
  135. pagination: {
  136. el: ".swiper-pagination",
  137. clickable: true,
  138. },
  139. navigation: {
  140. nextEl: ".swiper-button-next",
  141. prevEl: ".swiper-button-prev",
  142. },
  143. autoplay: {
  144. delay: 5000,
  145. disableOnInteraction: false,
  146. },
  147. });
  148. });
  149. </script>
  150. </body>
  151. </html>