首先,在主题文件夹下建立一个新 custom  文件,也就是自定义页面文件,命名为:tpl_tags.php

插入以下代码

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php
/**
 * _Tag Cloud_
 *
 * @package custom
 *
 */
?>
<?php  /*your code here*/  ?>
<?php
    $db = Typecho_Db::get();
    $options = Typecho_Widget::widget('Widget_Options');
    $tags= $db->fetchAll($db->select()->from('table.metas')
            ->where('table.metas.type = ?', 'tag')
            ->order('table.metas.order', Typecho_Db::SORT_DESC));
    foreach($tags AS $tag) {
        $type = $tag['type'];
        $routeExists = (NULL != Typecho_Router::get($type));
        $tag['pathinfo'] = $routeExists ? Typecho_Router::url($type, $tag) : '#';
        $tag['permalink'] = Typecho_Common::url($tag['pathinfo'], $options->index);
        echo "<a href=\"".$tag['permalink']."\">".$tag['name']."</a> ";
    }
?>
<?php  /*your code here*/  ?>

然后在后台添加一个独立页面,展开高级选项->自定义模板->Tag Cloud,缩略名写 tags 就可以了。

当然,你可以自己修改、添加相应代码,演示 http://mrasong.com/tags/