Call Us 203.687.6053

Blog with a focus on DotNetNuke news, tips and tricks, DNN SEO, and insights and opinions about the DNN community at large.

Fixing the DNN Breadcrumb Skin Object

Posted by Tom on Tuesday, January 29, 2008 to DotNetNuke, Downloads, DNN Tips and Tricks

We've all seen them; the bar of links usually found at the top of websites with multi-level navigation. Location breadcrumbs aide visitors in traversing content-rich sites by providing feedback on how "deep" visitors have navigated into the site and on how to get back where they came from. If properly implemented as text links, breadcrumbs also provide SEO benefits by allowing search engine spiders to more effortlessly crawl web content.

The DNN breadcrumb skin object, which is installed by default, makes it easy to implement breadcrumbs in your skins so there is really no excuse not to use them. Placing this line <dnn:Breadcrumb runat="server" id="dnnBreadcrumb" RootLevel="0" /> into your ascx-based skin renders the path to the currently selected tab in the form of TabName1 > TabName2 > TabName3. Optionally, you may specify a breadcrumb separator and a CSS class.

The only rub that I have with DNN's breadcrumb skin object is that the last item in the trail also renders as a link. You may think "what's the big deal," but I like to argue that this shortcoming works against the very benefits discussed above. Why would I want to navigate to the page that I'm already on?

So what's a dedicated DNNer to do? Here are 3 approaches one might take to "fix" the DNN breadcrumb skin object:

  1. Hack the breadcrumb trail with JavaScript.
  2. Modify the DNN skin object code.
  3. Write a custom breadcrumb skin object.

Let's look at these approaches one at a time.

JavaScript Hack

We simply target the last item in the breadcrumb trail and remove the href attribute. We then adjust the style due to the fact that even without a href attribute the <a> tag remains, which means it takes on the default link style although it's not a "live" link. Download the script here. Not the most elegant solution, but it works.

Modify the DNN Skin Object Code

This time around we add an additional public property - LastAsSpan - to the Public Members region of breadcrumb.ascx.vb that allows us to enable or disable the rendering of the last item in the breadcrumb trail as a link. Still in breadcrumb.ascx.vb, we then turn our attention to the Page_Load event handler and add a few lines of code that ultimately process our new setting. Download the commented code and then backup and replace breadcrumb.ascx.vb in admin/skins. No recompiling necessary, but you may have to restart DNN to clear the cache. For the politically correct, this constitutes a DNN core change and therefore gets overwritten by subsequent DNN upgrades. So again, far from ideal and more an illustration of concepts then a real-world solution.

Write a Custom Skin Object

This approach makes the most sense on all fronts and follows the "official" guidelines on extending DotNetNuke. Just install the custom skin object, register the new control and change the breadcrumb declaration in your existing skins and you are done. More details in the free download. I'm only a DNN module developer during REM though, so for anyone interested in the nitty-gritty of writing your own skin objects, keep an eye on Mitchel Sellers' blog later this week.

So there you have it, 3 roads to breadcrumb heaven. I'll leave it up to you to decide what approach works best for your unique situation.

In closing, I would like to thank Vasilis Terzopoulos and Mitchel Sellers for their generous contributions to this post. As always, post your comments and questions below. And if you have enjoyed this material, consider subscribing to our RSS feeds or signing up to get blog updates by email.

 


Permalink Permalink      Comments 7 Comments      RSS feeds RSS feeds      Email updates Email updates

 

Comments

Comment By Sam MacDonald on Tuesday, January 29, 2008 at 8:44 PM

Great article on how to accomplish this. I like the direction you took of writing about three options to accomplish the task. Instead of just taking and specifying one way of doing it.

Comment By Tom Kraak on Tuesday, January 29, 2008 at 9:40 PM

Thanks for picking up the post on your blog ... much appreciated!

Comment By Vitaly Kozadayev on Wednesday, January 30, 2008 at 11:46 AM

Great post. Quick note, though - in the email, all links are broken because HREFs are relative paths...

Also, can you give me some guidance/pointers on ASPDOTNETSTORE module? I just got it and wanted to learn from you, as you said elsewhere that you use it often?

Comment By Tom Kraak on Wednesday, January 30, 2008 at 12:07 PM

Sorry about the broken links in the email, I totally forgot.

ASPDNSF was generous enough to send me an eval copy for review, but I just haven't gotten around to it yet.

Do you have specific questions? Have you installed it yet?

Comment By erik on Thursday, January 31, 2008 at 10:09 AM

I like having the last page a link. It gives a quick way to reload the page.

Comment By Tom Kraak on Thursday, January 31, 2008 at 11:59 PM

Erik - I don't think most "casual" users browse the web on that level.

Comment By Mitchel Sellers on Wednesday, February 20, 2008 at 12:30 PM

I finally got the tutorial that Tom was talking about posted today. Sorry for the delay. You can click on my name in this signature to go directly to the article.

Add a comment
Add to Technorati Favorites

Email Updates

Enter your email address below and find our blog updates in your inbox.