farallon/page-archives.php

47 lines
1.9 KiB
PHP
Raw Normal View History

2024-05-17 15:47:27 +08:00
<?php
/**
* 文章归档
*
* @package custom
*/
if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
<?php $this->need('header.php'); ?>
<main class="site--main">
2024-05-18 09:24:49 +08:00
<header class="archive--header">
2024-05-17 15:47:27 +08:00
<h1 class="post--single__title"><?php $this->title() ?></h1>
<?php Typecho_Widget::widget('Widget_Stat')->to($quantity); ?>
<h2 class="archive--title__year">共包含 <?php $quantity->publishedPostsNum(); ?> 篇文章</h2>
2024-05-18 09:24:49 +08:00
</header>
<div class="page--archive" >
<?php
$stat = Typecho_Widget::widget('Widget_Stat');
2024-05-17 15:47:27 +08:00
Typecho_Widget::widget('Widget_Contents_Post_Recent', 'pageSize=' . $stat->publishedPostsNum)->to($archives);
$year = 0;
$mon = 0;
$i = 0;
$j = 0;
2024-05-18 09:24:49 +08:00
$output = '<div class="archives">';
while ($archives->next()) {
2024-05-17 15:47:27 +08:00
$year_tmp = date('Y', $archives->created);
$mon_tmp = date('m', $archives->created);
$y = $year;
$m = $mon;
if ($year > $year_tmp || $mon > $mon_tmp) {
2024-05-18 09:24:49 +08:00
$output .= '</ul>';
2024-05-17 15:47:27 +08:00
}
2024-05-18 09:24:49 +08:00
if ($year != $year_tmp || $mon != $mon_tmp) {
2024-05-17 15:47:27 +08:00
$year = $year_tmp;
$mon = $mon_tmp;
2024-05-18 09:24:49 +08:00
$output .= '<h2 class="archive--title__year">' . date('Y年', $archives->created) . '</h2>
2024-05-17 15:47:27 +08:00
<h3 class="archive--title__month">'. date('m月', $archives->created) .'</h3><ul class="archive--list" aria-label="' . date('Y年m月', $archives->created) . '">
'; //输出年份
}
2024-05-18 09:24:49 +08:00
$output .= '<li class="archive--item"><div class="archive--title"><a href="' . $archives->permalink . '">' . $archives->title . '</a></div>
2024-05-17 15:47:27 +08:00
<div class="archive--meta">' . date('m月d日', $archives->created) . '</div> </li>'; //输出文章
}
2024-05-18 09:24:49 +08:00
$output .= ' </ul></div>';
2024-05-17 15:47:27 +08:00
echo $output;?>
</div>
</main>
<?php $this->need('footer.php'); ?>