sky/archives.php

51 lines
2.2 KiB
PHP
Raw Normal View History

2021-07-25 09:12:40 +08:00
<?php
/**
* Sky 文章归档
*
* @package custom
*/
if (!defined('__TYPECHO_ROOT_DIR__')) exit;
$this->need('header.php');
?>
<div class="col mt-5" id="main" role="main">
<article>
<h1 class="font-weight-bold post-title">文章归档</h1>
<?php Typecho_Widget::widget('Widget_Stat')->to($stat);?><?php $stat->publishedPostsNum() ?> 篇文章,<?php echo allOfCharacters();?> 文字。
<hr>
<?php echo exContent($this->content); ?>
2021-08-16 09:39:35 +08:00
<form class="form-inline mb-3" id="search" method="post" action="<?php $this->options->siteUrl(); ?>" role="search">
<label class="sr-only" for="s">搜索文章</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">
<i class="fa fa-search"></i>
</span>
</div>
<input type="text" id="s" name="s" class="form-control" placeholder="输入关键字搜索" />
</div>
<button type="submit" class="form-control btn btn-secondary">搜索</button>
2021-08-16 09:39:35 +08:00
</form>
2021-07-25 09:12:40 +08:00
<?php
$this->widget('Widget_Contents_Post_Recent', 'pageSize=10000')->to($archives);
2021-08-04 12:29:14 +08:00
$year = 0; $mon = 0;
2021-07-25 09:12:40 +08:00
while ($archives->next()):
2021-08-04 12:29:14 +08:00
if (empty($archives->title) || $archives->title == " ") continue;
$year_tmp = date('Y',$archives->created);
$mon_tmp = date('m',$archives->created);
if ($year != $year_tmp && $year > 0) $output .= '</ul>';
if ($year != $year_tmp):
$year = $year_tmp;
$output .= '<h2>'. $year.'</h2><ul>';
endif;
$output .= '<li><span class="badge badge-secondary"><time>'.date('m-d ',$archives->created).'</time></span> <a href="'.$archives->permalink .'">'. $archives->title .'</a>';
if ($archives->commentsNum > 0) $output .= ' <span class="badge badge-secondary"><i class="far fa-comments"></i> '.$archives->commentsNum.'</span>';
$output .= '</li>';
2021-07-25 09:12:40 +08:00
endwhile;
2021-08-04 12:29:14 +08:00
$output .= '</li>';
2021-07-25 09:12:40 +08:00
echo $output;
?>
</article>
</div>
<?php $this->need('footer.php');
?>