From 1b8396cee17ac4c772ddc3adcda8252b1cbc2624 Mon Sep 17 00:00:00 2001 From: Eltrac Koalar Date: Thu, 26 Mar 2020 11:55:00 +0800 Subject: =?UTF-8?q?=F0=9F=9A=8C=20Add:=20=E6=94=AF=E6=8C=81=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E5=AF=BC=E8=88=AA=E6=A0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/Contents.php | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) (limited to 'libs/Contents.php') diff --git a/libs/Contents.php b/libs/Contents.php index d5cb522..51d97a6 100644 --- a/libs/Contents.php +++ b/libs/Contents.php @@ -151,15 +151,22 @@ class Contents return ''; } + /** + * 解析自定义导航栏 + */ + static public function paresNav($data) { + $de_json = json_decode($data, true); + $count_json = count($de_json); + for ($i = 0; $i < $count_json; $i++) { + $title = $de_json[$i]['title']; + $link = $de_json[$i]['link']; + //输出导航 + echo ''. $title .''; + } + } + + //从这里开始的代码来自 熊猫小A (https://imalan.cn) - /** - * 根据 id 返回对应的对象 - * 此方法在 Typecho 1.2 以上可以直接调用 Helper::widgetById(); - * 但是 1.1 版本尚有 bug,因此单独提出放在这里 - * - * @param string $table 表名, 支持 contents, comments, metas, users - * @return Widget_Abstract - */ /** * 为内容中的标题编号 @@ -172,6 +179,14 @@ class Contents return ''.$matchs[3].''; } + /** + * 根据 id 返回对应的对象 + * 此方法在 Typecho 1.2 以上可以直接调用 Helper::widgetById(); + * 但是 1.1 版本尚有 bug,因此单独提出放在这里 + * + * @param string $table 表名, 支持 contents, comments, metas, users + * @return Widget_Abstract + */ public static function widgetById($table, $pkId) { $table = ucfirst($table); -- cgit v1.2.3