当前位置:首页 > zblog

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

8976988823个月前 (01-08)zblog4

本文主要介绍的是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}


扫描二维码推送至手机访问。

版权声明:本文由米表程序发布,如需转载请注明出处。

本文链接:https://www.9909999.xyz/post/201.html

分享给朋友:

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