Selaa lähdekoodia

📦 修改显示问题

快乐的梦鱼 3 viikkoa sitten
vanhempi
commit
afe77e6f9c
8 muutettua tiedostoa jossa 128 lisäystä ja 77 poistoa
  1. 0 1
      components/navbar.php
  2. 1 1
      danWeiGaiKuang.php
  3. 4 4
      index.php
  4. 116 64
      luDaoWenMai.php
  5. 1 1
      search.php
  6. 1 1
      wenBaoJiaYuan.php
  7. 4 4
      xinWenXiangQing.php
  8. 1 1
      zhengCeFaGui.php

+ 0 - 1
components/navbar.php

@@ -4,7 +4,6 @@ $navItems = [
   ["name" => "党建工作", "url" => "/dangnJianGongZuo/"],
   ["name" => "单位概况", "url" => "/danWeiGaiKuang/"],
   ["name" => "工作动态", "url" => "/gongZuoDongTai/"],
-  ["name" => "文保家园", "url" => "/wenBaoJiaYuan/"],
   ["name" => "鹭岛文脉", "url" => "/luDaoWenMai/"],
   ["name" => "政策法规", "url" => "/zhengCeFaGui/"],
   ["name" => "联系我们", "url" => "/lianXiWoMeng/"]

+ 1 - 1
danWeiGaiKuang.php

@@ -35,7 +35,7 @@ if (!$currentArticle) {
     // 确保必要字段存在
     $currentArticle['title'] = isset($currentArticle['title']) ? $currentArticle['title'] : (isset($currentArticle['subject']) ? $currentArticle['subject'] : '无标题');
     $currentArticle['content'] = isset($currentArticle['content']) ? $currentArticle['content'] : '无内容';
-    $currentArticle['date'] = isset($currentArticle['date']) ? $currentArticle['date'] : (isset($currentArticle['createtime']) ? date('Y-m-d', strtotime($currentArticle['createtime'])) : date('Y-m-d'));
+    $currentArticle['date'] = isset($currentArticle['date']) ? $currentArticle['date'] : (isset($currentArticle['createtime']) ? date('Y-m-d', intval($currentArticle['createtime'])) : date('Y-m-d'));
     $currentArticle['views'] = isset($currentArticle['views']) ? $currentArticle['views'] : 0;
 }
 

+ 4 - 4
index.php

@@ -78,7 +78,7 @@ $featured = loadListByChannelName(6, "热门新闻");
                     <a href="/xinWenXiangQing/?id=<?php echo $notice['id']; ?>" class="notice-title"><?php echo $notice['title']; ?></a>
                     <p><?php echo $notice['description']; ?></p>
                   </div>
-                  <span class="notice-createtime"><?php echo $notice['createtime']; ?></span>
+                  <span class="notice-createtime"><?php echo date('Y-m-d', intval($notice['createtime'])); ?></span>
                 </div>
               <?php endforeach; ?>
             <?php else: ?>
@@ -90,7 +90,7 @@ $featured = loadListByChannelName(6, "热门新闻");
               <?php foreach ($hot as $item): ?>
                 <div class="news-item">
                   <a href="/xinWenXiangQing/?id=<?php echo $item['id']; ?>" class="title"><?php echo $item['title']; ?></a>
-                  <span class="createtime"><?php echo $item['createtime']; ?></span>
+                  <span class="createtime"><?php echo date('Y-m-d', intval($item['createtime'])); ?></span>
                 </div>
               <?php endforeach; ?>
             <?php else: ?>
@@ -139,7 +139,7 @@ $featured = loadListByChannelName(6, "热门新闻");
                 <?php foreach ($workUpcreatetimes as $upcreatetime): ?>
                   <div class="news-item">
                     <a href="/xinWenXiangQing/?id=<?php echo $upcreatetime['id']; ?>" class="title"><?php echo $upcreatetime['title']; ?></a>
-                    <span class="createtime"><?php echo $upcreatetime['createtime']; ?></span>
+                    <span class="createtime"><?php echo date('Y-m-d', intval($upcreatetime['createtime'])); ?></span>
                   </div>
                 <?php endforeach; ?>
               <?php else: ?>
@@ -160,7 +160,7 @@ $featured = loadListByChannelName(6, "热门新闻");
                 <?php foreach ($partyBuilding as $item): ?>
                   <div class="news-item">
                     <a href="/xinWenXiangQing/?id=<?php echo $item['id']; ?>" class="title"><?php echo $item['title']; ?></a>
-                    <span class="createtime"><?php echo $item['createtime']; ?></span>
+                    <span class="createtime"><?php echo date('Y-m-d', intval($item['createtime'])); ?></span>
                   </div>
                 <?php endforeach; ?>
               <?php else: ?>

+ 116 - 64
luDaoWenMai.php

@@ -9,19 +9,40 @@ $carouselItems = [
   ]
 ];
 
+// 主频道名称
+$mainChannelName = "鹭岛文脉";
+
+// 获取文保家园的子分类
+$sideMenu = loadChildChannelByChannelName($mainChannelName);
+
+// 获取URL参数 - 选中的频道
+$queryChannel = isset($_GET['channel']) ? trim($_GET['channel']) : '';
+
 // 获取URL参数 - 当前页码
 $currentPage = isset($_GET['page']) && is_numeric($_GET['page']) && $_GET['page'] > 0 ? intval($_GET['page']) : 1;
 
 // 每页显示的文章数量
 $pageSize = 6;
 
-// 主频道名称
-$mainChannelName = "鹭岛文脉";
+// 确定要查询的频道名称
+$channelToQuery = $queryChannel;
+if (empty($channelToQuery)) {
+    // 如果没有选中的频道或选中的频道不存在于子分类中,则使用主频道
+    $channelToQuery = $mainChannelName;
+}
 
 // 获取文章列表和总页数
-$articleResult = loadListByChannelNameAndPage($pageSize, $mainChannelName, $currentPage);
-$luDaoItems = $articleResult['list'];
+$articleResult = loadListByChannelNameAndPage($pageSize, $channelToQuery, $currentPage);
+$workUpdates = $articleResult['list'];
 $totalPages = $articleResult['totalPages'];
+
+// 如果查询的频道没有文章,则显示主频道的文章
+if (empty($workUpdates)) {
+    $articleResult = loadListByChannelNameAndPage($pageSize, $mainChannelName, $currentPage);
+    $workUpdates = $articleResult['list'];
+    $totalPages = $articleResult['totalPages'];
+    $channelToQuery = $mainChannelName;
+}
 ?>
 <!DOCTYPE html>
 <html lang="zh-CN">
@@ -60,71 +81,102 @@ $totalPages = $articleResult['totalPages'];
   <!-- 主要内容 -->
   <div class="main-content">
     <div class="container">
-        <div class="content">
-          
-          <!-- 精彩推荐网格布局 -->
-              <div class="featured-section">
-                <div class="section-title center large">
-                  <h2 class="icon">鹭岛文脉</h2>
-                </div>
-                <div class="featured-grid">
-                  <?php if (!empty($luDaoItems)): ?>
-                    <?php foreach ($luDaoItems as $item): ?>
-                      <div class="featured-card">
-                        <img 
-                          src="<?php echo isset($item['image']) ? $item['image'] : '/images/test-header-1.png'; ?>" 
-                          alt="<?php echo isset($item['title']) ? $item['title'] : '鹭岛文脉'; ?>"
-                        >
-                        <p>
-                          <a href="/xinWenXiangQing/?id=<?php echo isset($item['id']) ? $item['id'] : ''; ?>">
-                            <?php echo isset($item['title']) ? $item['title'] : ''; ?>
-                          </a>
-                        </p>
-                      </div>
-                    <?php endforeach; ?>
-                  <?php else: ?>
-                    <div class="no-news text-center w-100">暂无相关数据</div>
-                  <?php endif; ?>
-                </div>
+      <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>
-              
-              <!-- 分页 -->
-              <?php if ($totalPages > 1): ?>
-                <nav aria-label="List Page navigation" class="mt-6">
-                  <ul class="pagination justify-content-center">
-                    <!-- 上一页 -->
-                    <li class="page-item <?php echo $currentPage <= 1 ? 'disabled' : ''; ?>">
-                      <a 
-                        class="page-link" 
-                        href="?page=<?php echo $currentPage - 1; ?>" 
-                        aria-label="Previous"
-                      >
-                        <span aria-hidden="true">&laquo;</span>
+              <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 $queryChannel == $item['name'] ? 'active' : ''; ?>">
+                        <?php echo $item['name']; ?>
+                        <i class="fa fa-arrow-right"></i>
                       </a>
                     </li>
-                    
-                    <!-- 页码 -->
-                    <?php for ($i = 1; $i <= $totalPages; $i++): ?>
-                      <li class="page-item <?php echo $i == $currentPage ? 'active' : ''; ?>">
-                        <a class="page-link" href="?page=<?php echo $i; ?>">
-                          <?php echo $i; ?>
+                  <?php endforeach; ?>
+                <?php else: ?>
+                  <li>
+                    <a href="?channel=<?php echo urlencode($mainChannelName); ?>&page=1" class="active">
+                      <?php echo $mainChannelName; ?>
+                      <i class="fa fa-arrow-right"></i>
+                    </a>
+                  </li>
+                <?php endif; ?>
+              </ul>
+          </div>
+        </div>
+        <div class="col-12 col-sm-12 col-md-8 col-lg-9">
+          <div class="content">
+            
+            <!-- 精彩推荐网格布局 -->
+                <div class="featured-section">
+                  <div class="section-title center large">
+                    <h2 class="icon">鹭岛文脉</h2>
+                  </div>
+                  <div class="featured-grid">
+                    <?php if (!empty($luDaoItems)): ?>
+                      <?php foreach ($luDaoItems as $item): ?>
+                        <div class="featured-card">
+                          <img 
+                            src="<?php echo isset($item['image']) ? $item['image'] : '/images/test-header-1.png'; ?>" 
+                            alt="<?php echo isset($item['title']) ? $item['title'] : '鹭岛文脉'; ?>"
+                          >
+                          <p>
+                            <a href="/xinWenXiangQing/?id=<?php echo isset($item['id']) ? $item['id'] : ''; ?>">
+                              <?php echo isset($item['title']) ? $item['title'] : ''; ?>
+                            </a>
+                          </p>
+                        </div>
+                      <?php endforeach; ?>
+                    <?php else: ?>
+                      <div class="no-news text-center w-100">暂无相关数据</div>
+                    <?php endif; ?>
+                  </div>
+                </div>
+                
+                <!-- 分页 -->
+                <?php if ($totalPages > 1): ?>
+                  <nav aria-label="List Page navigation" class="mt-6">
+                    <ul class="pagination justify-content-center">
+                      <!-- 上一页 -->
+                      <li class="page-item <?php echo $currentPage <= 1 ? 'disabled' : ''; ?>">
+                        <a 
+                          class="page-link" 
+                          href="?page=<?php echo $currentPage - 1; ?>" 
+                          aria-label="Previous"
+                        >
+                          <span aria-hidden="true">&laquo;</span>
                         </a>
                       </li>
-                    <?php endfor; ?>
-                    
-                    <!-- 下一页 -->
-                    <li class="page-item <?php echo $currentPage >= $totalPages ? 'disabled' : ''; ?>">
-                      <a 
-                        class="page-link" 
-                        href="?page=<?php echo $currentPage + 1; ?>" 
-                        aria-label="Next"
-                      >
-                        <span aria-hidden="true">&raquo;</span>
-                      </a>
-                    </li>
-                  </ul>
-                </nav>
-              <?php endif; ?>
+                      
+                      <!-- 页码 -->
+                      <?php for ($i = 1; $i <= $totalPages; $i++): ?>
+                        <li class="page-item <?php echo $i == $currentPage ? 'active' : ''; ?>">
+                          <a class="page-link" href="?page=<?php echo $i; ?>">
+                            <?php echo $i; ?>
+                          </a>
+                        </li>
+                      <?php endfor; ?>
+                      
+                      <!-- 下一页 -->
+                      <li class="page-item <?php echo $currentPage >= $totalPages ? 'disabled' : ''; ?>">
+                        <a 
+                          class="page-link" 
+                          href="?page=<?php echo $currentPage + 1; ?>" 
+                          aria-label="Next"
+                        >
+                          <span aria-hidden="true">&raquo;</span>
+                        </a>
+                      </li>
+                    </ul>
+                  </nav>
+                <?php endif; ?>
+          </div>
         </div>
       </div>
     </div>

+ 1 - 1
search.php

@@ -96,7 +96,7 @@ $carouselItems = [
             // 确保所有必要字段存在
             $title = isset($item['title']) ? $item['title'] : '暂无标题';
             $articleId = isset($item['id']) ? $item['id'] : '';
-            $date = isset($item['createtime']) ? date('Y-m-d', strtotime($item['createtime'])) : '未知日期';
+            $date = isset($item['createtime']) ? date('Y-m-d', intval($item['createtime'])) : '未知日期';
             ?>
             <div class="news-item">
               <a href="/xinWenXiangQing/?id=<?php echo $articleId; ?>&keyword=<?php echo urlencode($searchKeyword); ?>" class="title"><?php echo $title; ?></a>

+ 1 - 1
wenBaoJiaYuan.php

@@ -138,7 +138,7 @@ if (empty($sideMenu) || empty($workUpdates)) {
                         <?php echo isset($item['title']) ? $item['title'] : ''; ?>
                       </a>
                       <span class="date">
-                        <?php echo isset($item['createtime']) ? date('Y-m-d', strtotime($item['createtime'])) : (isset($item['date']) ? $item['date'] : ''); ?>
+                        <?php echo isset($item['createtime']) ? date('Y-m-d', intval($item['createtime'])) : (isset($item['date']) ? $item['date'] : ''); ?>
                       </span>
                     </div>
                   <?php endforeach; ?>

+ 4 - 4
xinWenXiangQing.php

@@ -26,7 +26,7 @@ if (!$newsData) {
     // 确保必要字段存在
     $newsData['title'] = isset($newsData['title']) ? $newsData['title'] : (isset($newsData['subject']) ? $newsData['subject'] : '无标题');
     $newsData['content'] = isset($newsData['content']) ? $newsData['content'] : '无内容';
-    $newsData['date'] = isset($newsData['date']) ? $newsData['date'] : (isset($newsData['createtime']) ? date('Y-m-d', strtotime($newsData['createtime'])) : date('Y-m-d'));
+    $newsData['date'] = isset($newsData['date']) ? $newsData['date'] : (isset($newsData['createtime']) ? date('Y-m-d', intval($newsData['createtime'])) : date('Y-m-d'));
     $newsData['views'] = isset($newsData['views']) ? $newsData['views'] : 0;
     
     // 如果有channel_id,尝试获取频道名称
@@ -129,7 +129,7 @@ $carouselItems = [
             
             <!-- 相关文章 -->
             <?php if (isset($newsData['channel_id'])): ?>
-            <div class="related-news">
+            <div class="related-news mt-3">
               <h3>相关文章</h3>
               <ul>
                 <?php 
@@ -144,14 +144,14 @@ $carouselItems = [
                     
                     if ($relatedArticles) {
                       foreach ($relatedArticles as $article) {
-                        $articleDate = isset($article['createtime']) ? date('Y-m-d', strtotime($article['createtime'])) : '';
+                        $articleDate = isset($article['createtime']) ? date('Y-m-d', intval($article['createtime'])) : '';
                         echo "<li><a href='/xinWenXiangQing/?id={$article['id']}'>{$article['title']}</a><span>{$articleDate}</span></li>";
                       }
                     } else {
                       echo "<li>暂无相关文章</li>";
                     }
                   } catch (Exception $e) {
-                    echo "<li>获取相关文章失败</li>";
+                    echo "<li>暂无相关文章</li>";
                   }
                 ?>
               </ul>

+ 1 - 1
zhengCeFaGui.php

@@ -109,7 +109,7 @@ $totalPages = $articleResult['totalPages'];
                       <?php echo isset($item['title']) ? $item['title'] : ''; ?>
                     </a>
                     <span class="date">
-                      <?php echo isset($item['createtime']) ? date('Y-m-d', strtotime($item['createtime'])) : ''; ?>
+                      <?php echo isset($item['createtime']) ? date('Y-m-d', intval($item['createtime'])) : ''; ?>
                     </span>
                   </div>
                 <?php endforeach; ?>