前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Typecho 建立文章归档页面

Typecho 建立文章归档页面

作者头像
团团生活志
发布2022-08-16 08:32:48
4900
发布2022-08-16 08:32:48
举报
文章被收录于专栏:Live专区

在主题目录下创建archives.php页面

添加以下代码即可:

代码语言:javascript
复制
<?php if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
<?php   
/**  
* archives  
*  
* @Author GOJOGO 
*/  
$this->need('header.php'); ?>   
<div id="mainbox2">   
<div class="post"  id="post-<?php $this->cid(); ?>">   
<h3><span class="post-title"><a href="<?php $this->permalink() ?>" title=""><?php  $this->title() ?></a></span></h3>   
<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'); ?>
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2021-03-30,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档