wenBaoJiaYuan.php 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <?php
  2. require_once 'CommonQuery.php';
  3. // 轮播图数据 - 修改为单张图片
  4. $carouselItems = [
  5. [
  6. "image" => "/images/test-header-5.png",
  7. "alt" => "文保家园"
  8. ]
  9. ];
  10. // 获取文保家园的子分类
  11. $sideMenu = loadChildChannelByChannelName("文保家园");
  12. // 主频道名称
  13. $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 = 9;
  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($sideMenu) || 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>厦门市文化遗产保护中心 - <?php echo $channelToQuery; ?></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. <!-- 右侧内容 -->
  100. <div class="col-12 col-sm-12 col-md-8 col-lg-9">
  101. <div class="content">
  102. <div class="section-title">
  103. <h2 class="icon"><?php echo $channelToQuery; ?></h2>
  104. <nav aria-label="breadcrumb">
  105. <ol class="breadcrumb">
  106. <li class="breadcrumb-item"><a href="/">首页</a></li>
  107. <li class="breadcrumb-item"><a href="?channel=<?php echo urlencode($mainChannelName); ?>&page=1"><?php echo $mainChannelName; ?></a></li>
  108. <?php if ($queryChannel && $queryChannel != $mainChannelName): ?>
  109. <li class="breadcrumb-item active" aria-current="page"><?php echo $queryChannel; ?></li>
  110. <?php else: ?>
  111. <li class="breadcrumb-item active" aria-current="page"><?php echo $mainChannelName; ?></li>
  112. <?php endif; ?>
  113. </ol>
  114. </nav>
  115. </div>
  116. <!-- 文章列表 -->
  117. <div class="news-list">
  118. <?php if (!empty($workUpdates)): ?>
  119. <?php foreach ($workUpdates as $item): ?>
  120. <div class="news-item">
  121. <a href="/xinWenXiangQing/?id=<?php echo isset($item['id']) ? $item['id'] : (isset($item['title']) ? urlencode($item['title']) : ''); ?>" class="title">
  122. <?php echo isset($item['title']) ? $item['title'] : ''; ?>
  123. </a>
  124. <span class="date">
  125. <?php echo isset($item['createtime']) ? date('Y-m-d', intval($item['createtime'])) : (isset($item['date']) ? $item['date'] : ''); ?>
  126. </span>
  127. </div>
  128. <?php endforeach; ?>
  129. <?php else: ?>
  130. <div class="no-news">暂无相关文章</div>
  131. <?php endif; ?>
  132. </div>
  133. <!-- 分页 -->
  134. <?php if ($totalPages > 1): ?>
  135. <nav aria-label="List Page navigation">
  136. <ul class="pagination mt-4">
  137. <?php for ($i = 1; $i <= $totalPages; $i++): ?>
  138. <li class="<?php echo $i == $currentPage ? 'active' : ''; ?>">
  139. <a href="?channel=<?php echo urlencode($queryChannel); ?>&page=<?php echo $i; ?>">
  140. <?php echo $i; ?>
  141. </a>
  142. </li>
  143. <?php endfor; ?>
  144. </ul>
  145. </nav>
  146. <?php endif; ?>
  147. </div>
  148. </div>
  149. </div>
  150. </div>
  151. </div>
  152. <?php include __DIR__ . '/components/footer.php'; ?>
  153. <script>
  154. $(document).ready(function() {
  155. // 初始化 Swiper
  156. const swiper = new Swiper(".mySwiper", {
  157. slidesPerView: 1,
  158. spaceBetween: 30,
  159. loop: true,
  160. pagination: {
  161. el: ".swiper-pagination",
  162. clickable: true,
  163. },
  164. navigation: {
  165. nextEl: ".swiper-button-next",
  166. prevEl: ".swiper-button-prev",
  167. },
  168. autoplay: {
  169. delay: 5000,
  170. disableOnInteraction: false,
  171. },
  172. });
  173. });
  174. </script>
  175. </body>
  176. </html>