luDaoWenMai1.php 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. <?php
  2. require_once 'CommonQuery.php';
  3. // 轮播图数据 - 修改为单张图片
  4. $carouselItems = [
  5. [
  6. "image" => "/uploads/20251013/246147ec48aeefa28998917497f2ef6b.jpg",
  7. "alt" => "鹭岛文脉"
  8. ]
  9. ];
  10. // 主频道名称
  11. $mainChannelName = "鹭岛文脉";
  12. // 获取文保家园的子分类
  13. $sideMenu = loadChildChannelByChannelName($mainChannelName);
  14. // 获取URL参数 - 选中的频道
  15. $queryChannel = isset($_GET['channel']) ? trim($_GET['channel']) : '';
  16. // 获取URL参数 - 当前页码
  17. $currentPage = isset($_GET['page']) && is_numeric($_GET['page']) && $_GET['page'] > 0 ? intval($_GET['page']) : 1;
  18. // 每页显示的文章数量
  19. $pageSize = 6;
  20. // 确定要查询的频道名称
  21. $channelToQuery = $queryChannel;
  22. if (empty($channelToQuery)) {
  23. // 如果没有选中的频道或选中的频道不存在于子分类中,则使用主频道
  24. $channelToQuery = $mainChannelName;
  25. }
  26. // 获取文章列表和总页数
  27. $articleResult = loadListByChannelNameAndPage($pageSize, $channelToQuery, $currentPage);
  28. $workUpdates = $articleResult['list'];
  29. $totalPages = $articleResult['totalPages'];
  30. // 如果查询的频道没有文章,则显示主频道的文章
  31. if (empty($workUpdates)) {
  32. $articleResult = loadListByChannelNameAndPage($pageSize, $mainChannelName, $currentPage);
  33. $workUpdates = $articleResult['list'];
  34. $totalPages = $articleResult['totalPages'];
  35. $channelToQuery = $mainChannelName;
  36. }
  37. ?>
  38. <!DOCTYPE html>
  39. <html lang="zh-CN">
  40. <head>
  41. <meta charset="UTF-8">
  42. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  43. <title>厦门市文化遗产保护中心 - 鹭岛文脉</title>
  44. <link rel="stylesheet" href="/css/fonts.css">
  45. <link rel="stylesheet" href="/css/fontawesome.min.css">
  46. <link rel="stylesheet" href="/css/bootstrap.min.css">
  47. <link rel="stylesheet" href="/css/swiper-bundle.min.css">
  48. <link rel="stylesheet" href="/css/style.css">
  49. <script src="/js/jquery-3.7.1.js"></script>
  50. <script src="/js/bootstrap.bundle.js"></script>
  51. <script src="/js/swiper-bundle.min.js"></script>
  52. </head>
  53. <body>
  54. <?php include __DIR__ . '/components/navbar.php'; ?>
  55. <!-- 轮播图 -->
  56. <div class="swiper mySwiper" style="width: 100%; height: 400px;">
  57. <div class="swiper-wrapper">
  58. <?php foreach ($carouselItems as $item): ?>
  59. <div class="swiper-slide">
  60. <img src="<?php echo $item['image']; ?>" alt="<?php echo $item['alt']; ?>" style="width: 100%; height: 100%; object-fit: cover;">
  61. </div>
  62. <?php endforeach; ?>
  63. </div>
  64. <div class="swiper-pagination"></div>
  65. <div class="swiper-button-prev"></div>
  66. <div class="swiper-button-next"></div>
  67. </div>
  68. <!-- 主要内容 -->
  69. <div class="main-content">
  70. <div class="container">
  71. <div class="row">
  72. <!-- 左侧导航 -->
  73. <div class="col-12 col-sm-12 col-md-4 col-lg-3">
  74. <div class="sidebar">
  75. <div class="title">
  76. <h2><?php echo $mainChannelName; ?></h2>
  77. </div>
  78. <ul class="sidebar-menu">
  79. <?php if (!empty($sideMenu)): ?>
  80. <?php foreach ($sideMenu as $item): ?>
  81. <li>
  82. <a href="?channel=<?php echo urlencode($item['name']); ?>&page=1" class="<?php echo $queryChannel == $item['name'] ? 'active' : ''; ?>">
  83. <?php echo $item['name']; ?>
  84. <i class="fa fa-arrow-right"></i>
  85. </a>
  86. </li>
  87. <?php endforeach; ?>
  88. <?php else: ?>
  89. <li>
  90. <a href="?channel=<?php echo urlencode($mainChannelName); ?>&page=1" class="active">
  91. <?php echo $mainChannelName; ?>
  92. <i class="fa fa-arrow-right"></i>
  93. </a>
  94. </li>
  95. <?php endif; ?>
  96. </ul>
  97. </div>
  98. </div>
  99. <div class="col-12 col-sm-12 col-md-8 col-lg-9">
  100. <div class="content">
  101. <!-- 精彩推荐网格布局 -->
  102. <div class="featured-section">
  103. <div class="section-title center large">
  104. <h2 class="icon">鹭岛文脉</h2>
  105. </div>
  106. <div class="featured-grid">
  107. <?php if (!empty($luDaoItems)): ?>
  108. <?php foreach ($luDaoItems as $item): ?>
  109. <div class="featured-card">
  110. <img
  111. src="<?php echo isset($item['image']) ? $item['image'] : '/images/test-header-1.png'; ?>"
  112. alt="<?php echo isset($item['title']) ? $item['title'] : '鹭岛文脉'; ?>"
  113. >
  114. <p>
  115. <a href="/xinWenXiangQing/?id=<?php echo isset($item['id']) ? $item['id'] : ''; ?>">
  116. <?php echo isset($item['title']) ? $item['title'] : ''; ?>
  117. </a>
  118. </p>
  119. </div>
  120. <?php endforeach; ?>
  121. <?php else: ?>
  122. <div class="no-news text-center w-100">暂无相关数据</div>
  123. <?php endif; ?>
  124. </div>
  125. </div>
  126. <!-- 分页 -->
  127. <?php if ($totalPages > 1): ?>
  128. <nav aria-label="List Page navigation" class="mt-6">
  129. <ul class="pagination justify-content-center">
  130. <!-- 上一页 -->
  131. <li class="page-item <?php echo $currentPage <= 1 ? 'disabled' : ''; ?>">
  132. <a
  133. class="page-link"
  134. href="?page=<?php echo $currentPage - 1; ?>"
  135. aria-label="Previous"
  136. >
  137. <span aria-hidden="true">&laquo;</span>
  138. </a>
  139. </li>
  140. <!-- 页码 -->
  141. <?php for ($i = 1; $i <= $totalPages; $i++): ?>
  142. <li class="page-item <?php echo $i == $currentPage ? 'active' : ''; ?>">
  143. <a class="page-link" href="?page=<?php echo $i; ?>">
  144. <?php echo $i; ?>
  145. </a>
  146. </li>
  147. <?php endfor; ?>
  148. <!-- 下一页 -->
  149. <li class="page-item <?php echo $currentPage >= $totalPages ? 'disabled' : ''; ?>">
  150. <a
  151. class="page-link"
  152. href="?page=<?php echo $currentPage + 1; ?>"
  153. aria-label="Next"
  154. >
  155. <span aria-hidden="true">&raquo;</span>
  156. </a>
  157. </li>
  158. </ul>
  159. </nav>
  160. <?php endif; ?>
  161. </div>
  162. </div>
  163. </div>
  164. </div>
  165. </div>
  166. <?php include __DIR__ . '/components/footer.php'; ?>
  167. <script>
  168. $(document).ready(function() {
  169. // 初始化 Swiper
  170. const swiper = new Swiper(".mySwiper", {
  171. slidesPerView: 1,
  172. spaceBetween: 30,
  173. loop: true,
  174. pagination: {
  175. el: ".swiper-pagination",
  176. clickable: true,
  177. },
  178. navigation: {
  179. nextEl: ".swiper-button-next",
  180. prevEl: ".swiper-button-prev",
  181. },
  182. autoplay: {
  183. delay: 5000,
  184. disableOnInteraction: false,
  185. },
  186. });
  187. });
  188. </script>
  189. </body>
  190. </html>