• 搜索
  • 夜间模式
    ©2016-2025  周伯通的小站 Theme by OneBlog
    搜索
    标签
    # linux # python # android # 学习 # 折腾 # 教程 # 记录 # 软件 # vps # 新闻
  • 首页>
  • 分享>
  • 正文
  • 归档页面制作

    2017年06月19日 6 阅读 0 评论 1266 字

    创建自定义模版页面文件

    新建一个xx.php页面(这个xx随便你写什么名字但是不要中午哈)

    添加自定义模版标识

    将归档页面模版(xx.php)内第一行输入

    <?php
    /**
    * 归档(这个是名字)
    *
    * @package custom
    */
    $this->need('header.php'); ?>
    替换主体内容为输出归档文章列表

    将xx.php文件内输入

    <?php $this->widget('Widget_Contents_Post_Recent', 'pageSize=10000')->to($archives);
    $year=0; $mon=0; $i=0; $j=0;
    $output = '<div id="archives">';
    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>'. $mon .' 月</span><ul>'; //输出月份
    }
    $output .= '<li>'.date('d日: ',$archives->created).'<a href="'.$archives->permalink .'">'. $archives->title .'</a> <em>('. $archives->commentsNum.')</em></li>'; //输出文章日期和标题
    endwhile;
    $output .= '</ul></li></ul></div>';
    echo $output;
    ?>

    最后在底部加入

    <?php $this->need('header.php'); ?>

    一个简单的归档页面就完成了

    本文著作权归作者 [ 老周 ] 享有,未经作者书面授权,禁止转载,封面图片来源于 [ 互联网 ] ,本文仅供个人学习、研究和欣赏使用。如有异议,请联系博主及时处理。
    取消回复

    发表留言
    回复

    Copyright©2016-2025  All Rights Reserved.  Load:0.018 s
    Theme by OneBlog V3.6.4
    夜间模式

    开源不易,请尊重作者版权,保留基本的版权信息。