dangnJianGongZuo.php 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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="?channel=党建工作">党建工作<i class="fa fa-arrow-right"></i></a></li>
  73. <li><a href="?channel=党建要闻">党建要闻<i class="fa fa-arrow-right"></i></a></li>
  74. </ul>
  75. </div>
  76. </div>
  77. <!-- 右侧内容 -->
  78. <div class="col-12 col-sm-12 col-md-8 col-lg-9">
  79. <div class="content">
  80. <div class="section-title">
  81. <h2 class="icon"><?php echo $channel; ?></h2>
  82. <nav aria-label="breadcrumb">
  83. <ol class="breadcrumb">
  84. <li class="breadcrumb-item"><a href="/">首页</a></li>
  85. <li class="breadcrumb-item active" aria-current="page"><?php echo $channel; ?></li>
  86. </ol>
  87. </nav>
  88. </div>
  89. <!-- 文章列表 -->
  90. <div class="news-list">
  91. <?php if (!empty($partyBuilding)): ?>
  92. <?php foreach ($partyBuilding as $item): ?>
  93. <div class="news-item">
  94. <!-- 使用id作为文章详情页的参数,标题和日期字段可能需要根据实际数据库结构调整 -->
  95. <a href="/xinWenXiangQing/?id=<?php echo isset($item['id']) ? $item['id'] : $item['title']; ?>" class="title">
  96. <?php echo isset($item['title']) ? $item['title'] : (isset($item['subject']) ? $item['subject'] : ''); ?>
  97. </a>
  98. <span class="date">
  99. <?php echo date('Y-m-d', strtotime($item['createtime'])) ?>
  100. </span>
  101. </div>
  102. <?php endforeach; ?>
  103. <?php else: ?>
  104. <div class="no-news">暂无数据</div>
  105. <?php endif; ?>
  106. </div>
  107. <!-- 分页 -->
  108. <nav aria-label="List Page navigation">
  109. <ul class="pagination mt-4">
  110. <?php if ($totalPages > 0): ?>
  111. <?php for ($i = 1; $i <= $totalPages; $i++): ?>
  112. <li class="<?php echo $i == $currentPage ? 'active' : ''; ?>">
  113. <a href="?channel=<?php echo urlencode($channel); ?>&page=<?php echo $i; ?>">
  114. <?php echo $i; ?>
  115. </a>
  116. </li>
  117. <?php endfor; ?>
  118. <?php endif; ?>
  119. </ul>
  120. </nav>
  121. </div>
  122. </div>
  123. </div>
  124. </div>
  125. </div>
  126. <?php include __DIR__ . '/components/footer.php'; ?>
  127. <script>
  128. $(document).ready(function() {
  129. // 初始化 Swiper
  130. const swiper = new Swiper(".mySwiper", {
  131. slidesPerView: 1,
  132. spaceBetween: 30,
  133. loop: true,
  134. pagination: {
  135. el: ".swiper-pagination",
  136. clickable: true,
  137. },
  138. navigation: {
  139. nextEl: ".swiper-button-next",
  140. prevEl: ".swiper-button-prev",
  141. },
  142. autoplay: {
  143. delay: 5000,
  144. disableOnInteraction: false,
  145. },
  146. });
  147. });
  148. </script>
  149. </body>
  150. </html>