need("header.php"); ?> need('assets/lantern.html'); ?>
need("component/menu.php"); ?>
widget("Widget_Metas_Category_List"); $categoryArray = array(); // 重新遍历分类并存储到数组 $categories->reset(); while ($categories->next()) { $categoryArray[] = array( 'name' => $categories->name, 'permalink' => $categories->permalink, 'count' => $categories->count, 'description' => $categories->description ); } // 按文章数从多到少排序 usort($categoryArray, function($a, $b) { return $b['count'] - $a['count']; }); ?> 0): ?>
📁 按分类归档
🕰️ 按年份归档
widget('Widget_Contents_Post_Recent', 'pageSize=10000')->to($archives); // 先统计每个年份和月份的文章数量 $yearCount = array(); $monthCount = array(); $allPosts = array(); // 第一次遍历:收集所有文章并统计数量 while($archives->next()): $year_tmp = date('Y', $archives->created); $mon_tmp = date('m', $archives->created); $yearMonth = $year_tmp . '-' . $mon_tmp; // 统计年份文章数 if (!isset($yearCount[$year_tmp])) { $yearCount[$year_tmp] = 0; } $yearCount[$year_tmp]++; // 统计月份文章数 if (!isset($monthCount[$yearMonth])) { $monthCount[$yearMonth] = 0; } $monthCount[$yearMonth]++; // 处理标题长度 $title = $archives->title; if (mb_strlen($title, 'UTF-8') > 30) { $title = mb_substr($title, 0, 30, 'UTF-8') . '...'; } // 存储文章信息 $allPosts[] = array( 'year' => $year_tmp, 'month' => $mon_tmp, 'created' => $archives->created, 'permalink' => $archives->permalink, 'title' => $title, 'original_title' => $archives->title, // 保留原始标题用于tooltip 'commentsNum' => $archives->commentsNum, 'categories' => $archives->categories ); endwhile; // 按年份和月份排序(从新到旧) krsort($yearCount); krsort($monthCount); $output = ''; $currentYear = ''; $currentMonth = ''; foreach ($allPosts as $post): $year_tmp = $post['year']; $mon_tmp = $post['month']; // 获取分类信息 - 如果有分类就显示,没有就不显示 $categoryDisplay = ''; if (!empty($post['categories'])) { $category = current($post['categories']); $categoryName = $category['name']; $categoryPermalink = $category['permalink']; $categoryDisplay = '['.''. $categoryName .''.']'; } // 新年份开始 if ($currentYear != $year_tmp) { // 关闭前一个月份和年份 if ($currentMonth != '') { $output .= '
'; } if ($currentYear != '') { $output .= '
'; } $currentYear = $year_tmp; $currentMonth = ''; $yearTotal = isset($yearCount[$currentYear]) ? $yearCount[$currentYear] : 0; $output .= '
'; $output .= '

'. $currentYear .'' . $yearTotal . '[+]

'; $output .= ''; } $currentMonth = $mon_tmp; $yearMonth = $currentYear . '-' . $currentMonth; $monthTotal = isset($monthCount[$yearMonth]) ? $monthCount[$yearMonth] : 0; $output .= '
'; $output .= '

'. $currentMonth .'' . $monthTotal . '[+]

'; $output .= '
'; } if ($currentYear != '') { $output .= '
'; } echo $output; ?>
🗺️ 按足迹归档
widget("Widget_Metas_Tag_Cloud"); $tagArray = array(); // 重新遍历标签并存储到数组 $tags->reset(); while ($tags->next()) { // 跳过文章数为0的标签 if ($tags->count > 0) { $tagArray[] = array( 'name' => $tags->name, 'permalink' => $tags->permalink, 'count' => $tags->count ); } } // 按文章数从多到少排序 usort($tagArray, function($a, $b) { return $b['count'] - $a['count']; }); // 设置要显示的初始标签数量 $initialDisplayCount = 20; // 可以根据需要调整 $totalTags = count($tagArray); ?> 0): ?>
🏷️ 按标签归档
$initialDisplayCount): ?>
need("footer.php"); */?>