#
Typecho 2019-06-22

typecho导航栏调用分类目录

By 52naiba 209 Views 2 MIN READ 0 Comments

typecho的默认主题导航菜单部分调用的是独立页面,而我们搭建网站一般是把分类目录显示在导航栏,或者把分类目录和独立页面一起显示在导航栏,这样便于访客浏览网站目录。下面博客吧分享typecho分类目录显示在导航栏的代码。

只显示分类目录

在主题的header.php文件中找到代码:

```php+HTML
<?php $this->widget('Widget_Contents_Page_List')->to($pages); ?> <?php while($pages->next()): ?> slug)): ?> class="current" href="title(); ?>"> <?php endwhile; ?>


修改为以下代码:

```php
<?php $this->widget('Widget_Metas_Category_List')->to($category); ?> <?php while($category->next()): ?> <li><a<?php if($this->is('category', $category->slug)): ?> class="current"<?php endif; ?> href="<?php $category->permalink(); ?>" title="<?php $category->name(); ?>"><?php $category->name(); ?></a></li> <?php endwhile; }?>

分类目录和独立页面都显示

在主题的header.php文件中找到代码:

<?php $this->widget('Widget_Contents_Page_List')->to($pages); ?> <?php while($pages->next()): ?> <a<?php if($this->is('page', $pages->slug)): ?> class="current"<?php endif; ?> href="<?php $pages->permalink(); ?>" title="<?php $pages->title(); ?>"><?php $pages->title(); ?></a> <?php endwhile; ?>

在该代码上面添加代码:

```php+HTML
<?php $this->widget('Widget_Metas_Category_List')->to($category); ?> <?php while($category->next()): ?>

  • slug)): ?> class="current" href="name(); ?>">
  • <?php endwhile; }?>

    本文由 52naiba 原创

    采用 CC BY-NC-SA 4.0 协议进行许可

    转载请注明出处:https://nof1.de/Typecho/4.html

    TAGS: typecho

    0 评论

    发表评论