diff options
| author | Eltrac Koalar <hi@guhub.cn> | 2020-03-26 11:55:00 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-03-26 11:55:00 +0800 |
| commit | 1b8396cee17ac4c772ddc3adcda8252b1cbc2624 (patch) | |
| tree | c9b72ce7f044fe4262ed0ccc350864bde26b8698 /libs | |
| parent | c4c9aea33ab825731df06c440c43223d86504c58 (diff) | |
🚌 Add: 支持自定义导航栏
Diffstat (limited to 'libs')
| -rw-r--r-- | libs/Contents.php | 31 | ||||
| -rwxr-xr-x | libs/Options.php | 4 |
2 files changed, 26 insertions, 9 deletions
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 '<img class="owo-img" src="/usr/themes/Miracles/images/biaoqing/twemoji/'. str_replace('%', '', $match[1]) . '.png">'; } + /** + * 解析自定义导航栏 + */ + 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 '<a href="'. $link .'">'. $title .'</a>'; + } + } + + //从这里开始的代码来自 熊猫小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 '<h'.$matchs[1].$matchs[2].' id="'.$id.'">'.$matchs[3].'<a href="#'.$id.'" title="章节链接" class="post-toc-link no-line"><i class="iconfont icon-paragraph"></i></a></h'.$matchs[1].'>'; } + /** + * 根据 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); diff --git a/libs/Options.php b/libs/Options.php index 07b7c09..bd2a97d 100755 --- a/libs/Options.php +++ b/libs/Options.php @@ -89,8 +89,10 @@ function themeConfig($form) { //nav
$navStyle = new Typecho_Widget_Helper_Form_Element_Select('navStyle',array('0'=>'顶部导航栏','1'=>'左侧抽屉栏'),'0','<h2>导航栏 Nav</h2>类型','选择导航栏的类型(若选择左侧抽屉蓝,则下一条设置失效)');
$form->addInput($navStyle);
- $navAero = new Typecho_Widget_Helper_Form_Element_Select('navAero',array('0'=>'是','1'=>'否'),'0','顶部透明','视口处于最顶部时,顶部导航栏是否变为透明<hr>');
+ $navAero = new Typecho_Widget_Helper_Form_Element_Select('navAero',array('0'=>'是','1'=>'否'),'0','顶部透明','视口处于最顶部时,顶部导航栏是否变为透明');
$form->addInput($navAero);
+ $customNav = new Typecho_Widget_Helper_Form_Element_Textarea('customNav', NULL, NULL, _t('自定义导航栏'), _t('按照格式书写,自定义导航栏内容,留空则读取所有的独立页面,书写的格式请查看 wiki<hr>'));
+ $form->addInput($customNav);
//index-banner
$bannerUrl = new Typecho_Widget_Helper_Form_Element_Text('bannerUrl', NULL, NULL, _t('<h2>首页大图 Banner</h2>图片 Url'), _t('首页大图的图片地址'));
|
