首页 zblog内容详情

zblog分类目录面包屑的代码(分类+子分类)支持分类页、文章页

2026-01-08 3 897698882
zblog分类目录面包屑的代码(分类+子分类)支持分类页、文章页

站点名称:zblog分类目录面包屑的代码(分类+子分类)支持分类页、文章页

所属分类:zblog

官方网址:

SEO查询: 爱站网 站长工具

进入网站

站点介绍

本文主要介绍的是zblogphp模板中的面包屑导航,支持分类+子分类。

实际案例:《zblogphp最全面包屑导航代码,支持分类+子分类显示

zblog官方wiki也分享了代码,如图:

代码如下:

注意:

这是zblogphp文章页的分类+子分类面包屑,而不是分类页的面包屑!

{php}$html='';function navcate($id){        global $html;        $cate = new Category;        $cate->LoadInfoByID($id);        $html =' <i class="fa fa-angle-right"></i> <a href="' .$cate->Url.'" title="' .$cate->Name. '">' .$cate->Name. '</a>'.$html;        if(($cate->ParentID)>0){navcate($cate->ParentID);}}navcate($article->Category->ID);global $html;echo $html;{/php}

分类页分类+子分类面包屑:

{php}$html='';function navcate($id){        global $html;        $cate = new Category;        $cate->LoadInfoByID($id);        $html =' <i class="fa fa-angle-right"></i> <a href="' .$cate->Url.'" title="' .$cate->Name. '">' .$cate->Name. '</a>'.$html;        if(($cate->ParentID)>0){navcate($cate->ParentID);}}navcate($category->ID);global $html;echo $html;{/php}

所以,不同页面的面包屑中分类+子分类是不同的,必须区分,可以用《zblogIF页面判断》:

{if $type=='index'&&$page=='1'}  /*判断首页*/{template:index_default}{elseif $type=='category'}  /*判断分类页*/{$category.Name}{elseif $type=='article'}  /*判断日志页,不含独立{$article.Title}{template:index_artile}{elseif $type=='page'}  /*判断独立页面*/{template:index_page}{elseif $type=='author'}  /*判断用户页*/{$author.Name}/{$author.StaticName}{elseif $type=='date'}  /*判断日期页*/date- {$title}{elseif $type=='tag'}  /*判断标签页*/{$tag.Name}{else}{$title}{/if}