具体代码写法如下:
<div class="breadcrumb1 borderB"> <ul> <li>当前位置:</li> <li><a href="{$host}" title="{$name}首页">首页</a></li> {if $type=='category'||$type=='article'} {php} $html=''; function navcate($id){ global $html; $cate = new Category; $cate->LoadInfoByID($id); $html ='<li><i class="fa fa-angle-right"></i> <a href="' .$cate->Url.'" title="' .$cate->Name. '">'.$cate->Name.'</a></li>'.$html; if(($cate->ParentID)>0){ navcate($cate->ParentID); } } if($type=='category'){ navcate($category->ID); }else{ navcate($article->Category->ID); } global $html; echo $html; {/php} {if $type=='article'}<li><i class="fa fa-angle-right"></i> <a href="{$article.Url}">正文</a></li>{/if} {else}<li><i class="fa fa-angle-right"></i>{$title}</a></li> {/if} </ul></div>
以上代码放在任何模板页面均可生效,因为用了if判断type页面,首页、列表页、内容页、单页、tag页均可以显示正确的面包屑导航栏,与第一种对比,这一种写法更加全面和友好!