站点介绍
本文主要介绍的是zblogphp模板中的面包屑导航,支持分类+子分类。
实际案例:《zblogphp最全面包屑导航代码,支持分类+子分类显示》
zblog官方wiki也分享了代码,如图:
代码如下:
注意:
{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}