从Hexo转到Typecho,发现现在使用的这个模板没有分类界面。于是就在网上找分类界面,想偷懒找一个写好的分类界面,直接放在主题下。可是从百度到谷歌都没有找到一个很好的模板。最后实在没有办法,还是自己写吧。

其实,也不算自己写,我复制了主题中的文章归档的页面,在里面替换了相应的代码。

文章归档界面代码如下:

<?php
/**
* 归档模板
*
* @package custom
*/
$this->need('header.php'); ?>
    <div class="content">
        <div class="container">
            <div class="entry archive_list">
                <h1 class="entry-title">
                    <a itemtype="url" href="<?php $this->permalink() ?>"><?php $this->title() ?></a>
                </h1>
                <div class="post-content pl18" itemprop="articleBody">
                    <?php $this->widget('Widget_Contents_Post_Recent', 'pageSize=10000')->parse('<li><i>{year}-{month}-{day}</i> : <a href="{permalink}">{title}</a></li>'); ?>
                </div>
            </div>    
        </div>
    </div>
<?php $this->need('footer.php'); ?>

将第15行的内容替换为以下内容即可:(替换之前记得先复制一份备份)

<?php $this->widget('Widget_Metas_Category_List')->to($categorylist); ?>
                    <?php while($categorylist->next()): ?>
                        <li><a href="<?php $categorylist->permalink(); ?>" title="<?php $categorylist->name(); ?>"><?php $categorylist->name(); ?>(<?php $categorylist->count(); ?>)</a></li>
                    <?php endwhile; ?>

然后将模板改名,我这改为了分类模板,文件命名为category-list.php.然后将文件上至/var/www/html/usr/themes/terse目录下。

然后新建独立页面,选择模板“分类模板”即可。赶紧预览发布预览一下吧。