Allen 2020-07-02 14:38:21 3182 0 0 0 0

1、Typecho独立页面中添加自定义模板方法。

在主题文件夹下新建任意名称.php文件,加入代码:

<?php
/**
 * _模板命名
 *
 * @package custom
 *
 */ $this->need('header.php');
?>

@packge custom 这句固定格式

2,创建标签云自定义模板。

在主题文件夹下建立一个自定义页面模板,命名为:tpl_tags.php

插入以下代码:

<?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']."\"&gt;".$tag['name']."</a> ";
        }
    ?>    
<?php  /your code here/  ?>


3,创建标签云页面。

在后台添加一个独立页面,展开高级选项->自定义模板->Tag Cloud,缩略名写tags就可以了。
当然,你可以自己修改、添加相应代码

OK


【版權聲明】
本文爲原創,遵循CC 4.0 BY-SA版權協議!轉載時請附上原文鏈接及本聲明。
原文鏈接:https://tdlib.com/am.php?t=oTgcdCruaohw
Tag: Typecho 自制页面 标签云
我也要發一個   ·   返回首頁   ·   返回[Typecho]   ·   前一個   ·   下一個
歡迎評論
未登錄,
請先 [ 註冊 ] or [ 登錄 ]
(一分鍾即可完成註冊!)
返回首頁     ·   返回[Typecho]   ·   返回頂部