应网友 @贺晋军博客 留言zblogphp面包屑导航怎么制作的?网上的文章是以前的,求指点,谢谢
关于什么是面包屑导航我想各位童鞋都应该非常的了解了吧,这里我就不再叙述了;先贴两段官方WIKI给的代码看下:
页面判断{if $type=='index'&&$page=='1'} /*判断首页*/ {if $type=='category'} /*判断分类页*/ {if $type=='article'} /*判断日志页,不含独立页面,{if $article.Type==ZC_POST_TYPE_ARTICLE}(另一方案)*/ {if $type=='page'} /*判断独立页面*/ {if $type=='author'} /*判断用户页*/ {if $type=='date'} /*判断日期页*/ {if $type=='tag'} /*判断标签页*/
分类目录面包屑的代码编写{php} $html=''; function navcate($id){ global $html; $cate = new Category; $cate->LoadInfoByID($id); $html ='>> Url.'" title="查看' .$cate->Name. '中的全部文章">' .$cate->Name. ' '.$html; if(($cate->ParentID)>0){navcate($cate->ParentID);} } navcate($article->Category->ID); global $html; echo $html; {/php}
上面这两段代码是官方wiki给出的,我们只要结合下以上的代码稍做修改就可以了,下面我们来看下烽烟博客模板使用的面包屑导航代码:{if $type == 'index'} 网站改版调试中! {elseif $type == 'category'} 首页 {php} $html=''; function navcate($id){ global $html; $cate = new Category; $cate->LoadInfoByID($id); $html ='» Url.'" title="查看' .$cate->Name. '中的全部文章">' .$cate->Name. ' '.$html; if(($cate->ParentID)>0){navcate($cate->ParentID);} } navcate($category->ID); global $html; echo $html; {/php} {elseif $type =="article"} 首页 {php} $html=''; function navcate($id){ global $html; $cate = new Category; $cate->LoadInfoByID($id); $html ='» Url.'" title="查看' .$cate->Name. '中的全部文章">' .$cate->Name. ' '.$html; if(($cate->ParentID)>0){navcate($cate->ParentID);} } navcate($article->Category->ID); global $html; echo $html; {/php} » 正文 {elseif $type =="page"} 首页 » 正文 {elseif $type =="tag"} 首页 » 标签存档:{$tag.Name} {elseif $type =="author"} 首页 » {$author.Name} 的文章 {/if}
将上面的代码添加到你想要显示的地方就行了,不过一般都在导航栏下方,效果可以参考烽烟博客。