diff options
| author | LiCaoZ <admin@licaoz.com> | 2023-03-16 21:22:20 +0800 |
|---|---|---|
| committer | LiCaoZ <admin@licaoz.com> | 2023-03-16 21:22:20 +0800 |
| commit | 02947175352b377114bf3e4c7bf524cc02cf937b (patch) | |
| tree | 191421df3d319536ee3f439f46001afb9763f740 | |
| parent | be8ad30eb6d76c88d9fbdf0df9723834d3a66695 (diff) | |
:newspaper: Feat: 支持分类导航 & 部分导航逻辑重构
| -rw-r--r-- | includes/header.php | 2 | ||||
| -rw-r--r-- | includes/sidebar.php | 6 | ||||
| -rw-r--r-- | libs/Matcha.php | 25 | ||||
| -rw-r--r-- | libs/Options.php | 12 |
4 files changed, 39 insertions, 6 deletions
diff --git a/includes/header.php b/includes/header.php index a74b47a..c1cf591 100644 --- a/includes/header.php +++ b/includes/header.php @@ -18,7 +18,7 @@ $this->need("includes/head.php"); ?> <div class="navbar-dropdown"> <button class="navbar-button navbar-dropup" id="nav-rise"><span>+</span></button> <h2>页面</h2> - <ul class="widget-list"><?php Matcha::pageNav($this, "li"); ?></ul> + <ul class="widget-list"><li><a href="<?php $this->options->siteUrl(); ?>" rel="section">首页</a></li><?php Matcha::pageNav($this, "li"); ?></ul> <h2>分类</h2> <ul class="widget-list widget-category"> <?php $this->widget('Widget_Metas_Category_List')->to($categories); ?> diff --git a/includes/sidebar.php b/includes/sidebar.php index 32df2e7..77109e9 100644 --- a/includes/sidebar.php +++ b/includes/sidebar.php @@ -3,7 +3,11 @@ <aside id="sidebar" class="sidebar" role="complementary"> <section class="widget widget-nav sidebar-nav"> <header id="header" class="header"><?php Matcha::siteName(); ?></header> - <ul class="widget-list"><?php Matcha::pageNav($this, "li"); ?></ul> + <ul class="widget-list"> + <li><a href="<?php $this->options->siteUrl(); ?>" rel="section">首页</a></li> + <?php Matcha::categoryNav($this, "li"); ?> + <?php Matcha::pageNav($this, "li"); ?> + </ul> </section> <!-- 版权信息 --> <section class="widget sidebar-foot"> diff --git a/libs/Matcha.php b/libs/Matcha.php index 7044d85..6ae4fb9 100644 --- a/libs/Matcha.php +++ b/libs/Matcha.php @@ -264,10 +264,6 @@ class Matcha if(Helper::options()->customNav=='' || $data['type']=='addition'){ $archive->widget('Widget_Contents_Page_List')->to($pages); - //首页链接 - echo '<'.$tag.'><a href="'; - Utils::indexHome(); - echo '">首页</a></'.$tag.'>'; //页面列表 while($pages->next()) { echo '<'.$tag.'><a href="'; @@ -288,6 +284,27 @@ class Matcha } /** + * 统一输出分类导航 + * html 结构 + */ + public static function categoryNav(Widget_Archive $archive, $tag) + { + // 如果开启了分类导航,则输出分类 + if(Helper::options()->categoryNav=='able') { + $archive->widget('Widget_Metas_Category_List')->to($categories); + while($categories->next()) { + echo '<'.$tag.'><a href="'; + $categories->permalink(); + echo '" title="'; + $categories->name(); + echo '">'; + $categories->name(); + echo '</a></'.$tag.'>'; + } + } + } + + /** * 统一输出站点标题及副标题 * html 结构 */ diff --git a/libs/Options.php b/libs/Options.php index ef12f80..3f9964d 100644 --- a/libs/Options.php +++ b/libs/Options.php @@ -70,6 +70,18 @@ function themeConfig($form) { $relatedLinks = new Typecho_Widget_Helper_Form_Element_Textarea('relatedLinks', NULL, NULL, _t('首页「相关链接」内容'), _t(' <p class="description">使用特定的 JSON 格式书写,可以在首页文章目录之前展示一个相关链接版块,详情请查看说明文档</p>')); $form->addInput($relatedLinks); + // 分类导航 + $categoryNav = new Typecho_Widget_Helper_Form_Element_Radio('categoryNav', array( + 'able' => _t('启用'), + 'disable' => _t('停用'), + ), + 'disable', + _t('是否启用侧边栏分类导航'), + _t(' + 启用后,将在侧边栏首页和独立页面中间加入所有分类页面。 + ') + ); + $form->addInput($categoryNav->addRule('required', _t('此处必须设置'))); /** * 附加功能 |
