typecho的面包屑导航

原版面包屑代码

<div class="crumbs_patch">
    <a href="<?php $this->options->siteUrl(); ?>">Home</a> &raquo;</li>
    <?php if ($this->is('index')): ?><!-- 页面为首页时 -->
        Latest Post
    <?php elseif ($this->is('post')): ?><!-- 页面为文章单页时 -->
        <?php $this->category(); ?> &raquo; <?php $this->title() ?>
    <?php else: ?><!-- 页面为其他页时 -->
        <?php $this->archiveTitle(' &raquo; ','',''); ?>
    <?php endif; ?>
</div>

改进版的面包屑导航代码

<div class="crumbs_patch">
    <a href="<?php $this->options->siteUrl(); ?>">Home</a> &raquo;</li>
    <?php if ($this->is('index')): ?><!-- 页面为首页时 -->
        Latest Post
    <?php elseif ($this->is('post')): ?><!-- 页面为文章单页时 -->
        <?php $this->directory(); ?> / <a href="<?php $this->permalink() ?>"><?php $this->title() ?></a><!-- 增加分类链接,同时增加多级分类的显示 -->
    <?php else: ?><!-- 页面为其他页时 -->
        <?php $this->archiveTitle(' &raquo; ','',''); ?>
    <?php endif; ?>
</div>

修改说明

改进代码的主要在第六行,增加了分类的链接,可以直接返回分类。同时将category();修改为directory();,为了增加多级分类显示,这样面包屑导航才是真正的面包屑,你说是不是?

实际情况并不理想,如果一个文章归属多个分类,则只能显示一个,所以还是用category();

扫一扫,访问移动端

高凯的个人主页
I am alone on my life's Journey up to now, and the future.

推荐 / Digest

热点 / Hot

评论 / Comments

  • Gaobukai: 这个点赞的按钮为什么总报错呢?
  • Gaobukai: 既然能调用0号图片就能调用随机图片<?php rand(0...
  • Gaobukai: 我这里没有这个问题,不知道哪里出的问题,需要的话加我微信看看什么情况吧
  • hu bill: 我也是这样的
  • hu bill: 对
  • : 上传头像,弹出框显示[object object],并一直显示在...

标签 / Tags

推广 / Ads