| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- <?php
- // 引入公共查询类
- require_once 'CommonQuery.php';
- // 主频道名称
- $mainChannelName = '工作动态';
- // 使用loadChildChannelByChannelName函数获取子分类
- $sideMenu = loadChildChannelByChannelName($mainChannelName);
- // 获取URL参数
- $selectedChannel = isset($_GET['channel']) ? $_GET['channel'] : '';
- $currentPage = isset($_GET['page']) ? intval($_GET['page']) : 1;
- // 验证当前页码
- if ($currentPage < 1) {
- $currentPage = 1;
- }
- // 每页显示的文章数量
- $pageSize = 12;
- // 确定要查询的频道名称
- $queryChannel = !empty($selectedChannel) ? $selectedChannel : $mainChannelName;
- // 使用loadListByChannelNameAndPage函数获取文章列表
- $results = loadListByChannelNameAndPage($pageSize, $queryChannel, $currentPage);
- $workUpdates = $results['list'];
- $totalPages = $results['totalPages'];
- // 如果没有结果但选择了子分类,尝试查询主频道
- if (empty($workUpdates) && !empty($selectedChannel)) {
- $results = loadListByChannelNameAndPage($pageSize, $mainChannelName, 1);
- $workUpdates = $results['list'];
- $totalPages = $results['totalPages'];
- $currentPage = 1;
- $queryChannel = $mainChannelName;
- }
- // 轮播图数据
- $carouselItems = [
- [
- "image" => "/images/test-header-4.png",
- "alt" => $mainChannelName
- ]
- ];
- ?>
- <!DOCTYPE html>
- <html lang="zh-CN">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>厦门市文化遗产保护中心 - <?php echo $queryChannel; ?></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-12 col-sm-12 col-md-4 col-lg-3">
- <div class="sidebar">
- <div class="title">
- <h2><?php echo $mainChannelName; ?></h2>
- </div>
- <ul class="sidebar-menu">
- <?php if (!empty($sideMenu)): ?>
- <?php foreach ($sideMenu as $item): ?>
- <li><a href="?channel=<?php echo urlencode($item['name']); ?>&page=1" class="<?php echo $selectedChannel == $item['name'] ? 'active' : ''; ?>"><?php echo $item['name']; ?><i class="fa fa-arrow-right"></i></a></li>
- <?php endforeach; ?>
- <?php else: ?>
- <li class="no-content">暂无相关子分类</li>
- <?php endif; ?>
- </ul>
- </div>
- </div>
-
- <!-- 右侧内容 -->
- <div class="col-12 col-sm-12 col-md-8 col-lg-9">
- <div class="content">
- <div class="section-title">
- <h2 class="icon"><?php echo $queryChannel; ?></h2>
-
- <nav aria-label="breadcrumb">
- <ol class="breadcrumb">
- <li class="breadcrumb-item"><a href="/">首页</a></li>
- <li class="breadcrumb-item"><a href="./">工作动态</a></li>
- <?php if ($selectedChannel): ?>
- <li class="breadcrumb-item active" aria-current="page"><?php echo $selectedChannel; ?></li>
- <?php else: ?>
- <li class="breadcrumb-item active" aria-current="page">工作动态</li>
- <?php endif; ?>
- </ol>
- </nav>
- </div>
-
- <!-- 文章列表 -->
- <div class="news-list">
- <?php if (!empty($workUpdates)): ?>
- <?php foreach ($workUpdates as $item): ?>
- <?php
- // 确保所有必要字段存在
- $title = isset($item['title']) ? $item['title'] : '暂无标题';
- $articleId = isset($item['id']) ? $item['id'] : '';
- $date = isset($item['createtime']) ? date('Y-m-d', strtotime($item['createtime'])) : '未知日期';
- ?>
- <div class="news-item">
- <a href="/xinWenXiangQing/?id=<?php echo $articleId; ?>&channel=<?php echo urlencode($queryChannel); ?>" class="title"><?php echo $title; ?></a>
- <span class="date"><?php echo $date; ?></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">
- <li class="prev"><a href="?channel=<?php echo urlencode($selectedChannel); ?>&page=<?php echo $currentPage > 1 ? $currentPage - 1 : 1; ?>"><</a></li>
- <?php for ($i = 1; $i <= $totalPages; $i++): ?>
- <li class="<?php echo $i == $currentPage ? 'active' : ''; ?>"><a href="?channel=<?php echo urlencode($selectedChannel); ?>&page=<?php echo $i; ?>"><?php echo $i; ?></a></li>
- <?php endfor; ?>
- <li class="next"><a href="?channel=<?php echo urlencode($selectedChannel); ?>&page=<?php echo $currentPage < $totalPages ? $currentPage + 1 : $totalPages; ?>">></a></li>
- </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>
|