Typecho 创建文章归档页面的实现方法(非插件)

这个归档相信大家都不陌生,因为本人是先从wordpress开始的,所以在wp实现了这个之后跳到typecho必须也要实现这个,好在开源什么都可以通过代码实现,

下面就分享下typecho如何非插件实现文章归档页面,其实挺简单的,按照下面的搞起,分分钟的事情!
首先 复制page.php一枚,重命名为archives,当然,这个可以根据自己的喜好随便起名

其次 按照下面的替换其中的代码,从而可以让主题识别这个归档独立页面

PHP Code复制内容到剪贴板
  1. $this->need('header.php'); ?>   
替换为

PHP Code复制内容到剪贴板
  1.     /**  
  2.     * archives  
  3.     *  
  4.     * @package custom  
  5.     */  
  6.     $this->need('header.php'); ?>   
第三 接著按照以下代码进行替换,其替换的代码为归档的核心代码

PHP Code复制内容到剪贴板
  1. $this->content(); ?>   
替换为


复制代码
代码如下:

widget('Widget_Contents_Post_Recent', 'pageSize=10000')->parse('
  • {year}-{month}-{day} : {title}
  • '); ?>


    到此归档页面已经创建完成,接著上传到主题目录,然后进入typecho后台新建page页面,然后选择模板为archives,如果开始创建这个页面的时候不是取的这个名字请自行选择!下面分享一个现成的独立页面,直接新建一个page.php页面,代码全部复制进去即可!

    PHP Code复制内容到剪贴板
    1. /**  
    2.     * archives  
    3.     *  
    4.     * @package custom  
    5.     */  
    6. $this->need('header.php'); ?>   
    7.     "mainbox2">   
    8.         class="position">当前位置:"./">首页 » $this->title() ?>
      
  •         class="post"  id="post-cid(); ?>">   
  •             

    class="float_l">"permalink() ?>" title="">$this->title() ?>

      
  •             class="clear">
  •   
  •             class="entry">   
  • $this->widget('Widget_Contents_Post_Recent','pageSize=10000')->parse('
  • {year}-{month}-{day} : {title}
  • '); ?>   
  •                 class="clear">
  •   
  •             
  •   
  •         
  •   
  •           
  • 赞(0) 打赏
    未经允许不得转载:0133技术站首页 » CMS教程