自己参照各种版本的教程,整出一个这样的归档页面来,没有加载js,全部就是几行代码而已,好记性不如烂笔头,喜欢的同学直接拿去,不谢!
在主题文件夹根目录新建文件 archives.php ,代码如下:
<?php if(!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
<?php
/**
* 归档
*
* @package custom
*/
$this->need('header.php'); ?>
<header>
<a href="<?php $this->options->siteUrl(); ?>"><?php $this->options->title(); ?></a><span class="slash">/</span>
<h1><?php $this->title(); ?></h1>
</header>
<h4>分类</h4>
<div class="post-content pl18" itemprop="articleBody">
<?php $this->widget('Widget_Metas_Category_List')
->parse('<a href="{permalink}">{name}({count})</a> '); ?>
</div>
<div id="mainboxs">
<div class="post" id="post-<?php $this->cid(); ?>">
<div class="clear"></div>
<div class="entry">
<?php $this->widget('Widget_Contents_Post_Recent', 'pageSize=10000')->to($archives);
$year=0; $mon=0; $i=0; $j=0;
$output = '<div class="post-content cf">';
while($archives->next()):
$year_tmp = date('Y',$archives->created);
$mon_tmp = date('m',$archives->created);
$y=$year; $m=$mon;
if ($mon != $mon_tmp && $mon > 0) $output .= '</ul></li>';
if ($year != $year_tmp && $year > 0) $output .= '</ul>';
if ($year != $year_tmp) {
$year = $year_tmp;
$output .= '<h3>'. $year .' 年</h3><ul>';
}
if ($mon != $mon_tmp) {
$mon = $mon_tmp;
$output .= '<li><span>'. $year .' 年'. $mon .' 月</span><ul>';
}
$output .= '<li>'.date('d日: ',$archives->created).'<a href="'.$archives->permalink .'">'. $archives->title .'</a> ('. $archives->commentsNum.')</li>';
endwhile;
$output .= '</ul></li></ul></div>';
echo $output;
?>
<div class="clear"></div>
</div>
</div>
</div>
<?php $this -> need('footer.php'); ?>
暂无评论