Abstract your Crumbtrails

By Deane Barker on May 14, 2010

Here’s a really, really esoteric CMS implementation tip: abstract your crumbtrails.

What I mean is to make sure your crumbtrails can be generated from something other than the content in the CMS.  I’ve finally learned this for good.

I’m in a middle of an Episerver implementation now.  Episerver has a strong content tree, so I wrote a quick control to iterate through a page’s ancestors and form up a crumbtrail.  This is great...until you get one of these situations:

  1. You have a page not in the content structure of the CMS.  Some page that sits outside the CMS.  In any project of appreciable size, you will have these.

  2. You have a page that maps to a single content item, but has different logical states which require different crumbtrail navigation.  Based on certain criteria, the page might have more than one state, but insofar as the CMS is concerned, it’s the same content object, so the crumbtrail is the same.

You need to have an abstraction layer for crumbtrails.  You should have some method for “AddCrumbtrailSegment” which takes a title and a URL.  Then, if you have a page outside the CMS, you can form a crumbtrail from scratch, or, with a single call, you can add a segment to an existing crumbtrail.

If you’re working with a page that’s solidly in the CMS, feel free to use the CMS structure to form up the crumbtrail, but use your abstraction layer to do it.  In the end, forming the crumbtrail from the CMS structure should be one way to do it, not the only way to do it.

This tip probably holds true for any navigation element in the outer layout of a CMS template – general navigation, footer items, overhead static menu items, etc.

Told you it was esoteric.

Comments (2)

Molly says:

Can this also work for site pages that you want to be able to create more than one trail for? So if they navigate to it from one place it’s in this trail and from another it’s from another etc.

Also since I’m not a programmer, don’t know if there is an obvious answer to this... Is this an episerver-specific concept or can it be implemented in any CMS?

Deane says:

No, this really doesn’t have any applicability to the poly-hierarchical problem. I discussed that several years ago here:

Of Taxonomies and Crumbtrails

There’s still no great solution to that problem – it’s much more of a logical issue, rather than a technical issue.

And this is not specific to Episerver, though other systems might have problems implementing this pattern. Ektron, in particular, rolls their crumbtrails up into a single .Net control, so you can’t modify it.

Episerver doesn’t give you a pre-packaged crumbtrail control. We just iterate up the content tree from the current page to form it. What we need to do (we finally learned this lesson) is to iterate up the tree and call a method like AddCrumbtrailSegment so that the method of displaying the crumbtrail is abstracted away from where the data comes from – you can “power” a crumbtrail from any datastore, in other words, whether that’s your CMS or anything else.