Breadcrumbs

 Here is a breadcrumbs dealy bob that sits under the bar for results of archive, search, or label or over the post or page.

It is written as an includable, called as follows:

in <b:widget id='Blog1' inside and at beginning of <b:includable id='main'>, right before <b:include name='noContentPlaceholder'/>


<b:include name='breadcrumbs'/>

then a little further down, before the next includable,


<b:includable id='breadcrumbs'>
<b:if cond='data:view.url != data:blog.homepageUrl'>
  <div id='breadcrumbs'>
  <a expr:href='data:blog.homepageUrl'><data:messages.home/></a> &#187; 
<b:if cond='data:view.isSingleItem and not data:view.isPage'>
<b:loop values='data:posts' var='post'>
<b:if cond='data:post.labels'>
<b:loop index='i' values='data:post.labels' var='label'>
<b:if cond='data:i == 0'><a expr:href='data:label.url' rel='tag'><data:label.name/></a> &#187; 
</b:if>
</b:loop>
</b:if>
<data:post.title/>
</b:loop>
<b:else/>
<b:if cond='data:view.isArchive'>
  Archive &#187; 
</b:if>
<data:blog.pageName/>
</b:if>
  </div>
</b:if>
</b:includable>


If, instead of the above, for the breadcrumbs trail to appear above and not below the results bar, it is necessary to have the code in 2 parts because of the data:posts for the label loop not being available outside of the Blog1 widget, so the breadcrumbs won't work for the single items there. So in that case, just after the </header> tag,


<!-- breadcrumbs -->
<b:if cond='(data:view.isMultipleItems and data:view.url != data:blog.homepageUrl) or data:view.isPage'>
  <div id='breadcrumbs'>
  <a expr:href='data:blog.homepageUrl'><data:messages.home/></a> &#187; 
<b:if cond='data:view.isArchive'>
  Archive &#187; 
</b:if>
<data:blog.pageName/>
  </div>
</b:if>
<!-- breadcrumbs end -->

and then just for the single posts, instead of the other includable but called from the same place as above,


<b:includable id='breadcrumbs'>
<b:if cond='data:view.isSingleItem and not data:view.isPage'>
  <div id='breadcrumbs'>
  <a expr:href='data:blog.homepageUrl'><data:messages.home/></a> &#187; 
<b:loop values='data:posts' var='post'>
<b:if cond='data:post.labels'>
<b:loop index='i' values='data:post.labels' var='label'>
<b:if cond='data:i == 0'><a expr:href='data:label.url' rel='tag'><data:label.name/></a> &#187; 
</b:if>
</b:loop>
</b:if>
<data:post.title/>
</b:loop>
</div>
</b:if>
</b:includable>

 

Comments (3)