I have received several emails asking about a simple Breadcrumb snippet for Graffiti CMS template .view files. I hadn't jumped on it because I just figured it was simple to do. Then I had to implement one for a client, and I realized it could be a little tricky to do just with straight Chalk.
I found this article on Google and posted a reply with a basic breadcrumb for sites that only require a Category > Subcategory > Post deep structure.
About 5 minutes after replying, I realized I had been a little lazy and have adjusted it to handle Categories and Subcategories that do not have default posts assigned.
1) Create a breadcrumb.view file with the following code:
<div class="breadcrumb"><a href="/">Home</a> |
#if($macros.IsNull($category.Parent.name))
<a href="/$category.name">$category.name</a>
#else
<a href="/$category.Parent.name">$category.Parent.name</a> | <a href="/$category.Parent.name/$category.name">$category.name</a>
#end
#if(!$macros.IsNull($url)&&!$macros.IsNull($post.Title))
| <a href="$url">$post.Title</a>
#end
</div>
You can edit the look and feel of this breadcrumb however you would like, obviously.
2) Add this line of code in your template (.view file) wherever you would like to implement the breadcrumb:
$macros.LoadThemeView("breadcrumb.view")
3) Make sure you have .breadcrumb class in your stylesheet to edit the look and feel.
I hope this helps, and have fun!





