Breadcrumb support?

Topics: Standard packages
Mar 26, 2011 at 7:28 AM

I apologize if this has already been discussed. I tried searching for breadcrumbs and pathways but couldn't get anything. I have an existing site that I'm trying to evaluate in C1 to see if it will meet our needs but one thing we currently have is a display on all sub pages of the 'trail' that the user has followed...

Home > Products > Product X

or

Stores > Locations > Country > State > City > Store 1

 

If anyone has any insight to an existing function that will accomplish this or knows a simple way to include this utilizing the already existing tree structure that C1 provides, I would be very grateful.

Mar 26, 2011 at 9:12 AM
Edited Mar 26, 2011 at 9:13 AM

Are we talking xslt or pure asp.net here? In asp.net for instance, we can use the SiteMapProvider, which is a standard way of representing a SiteMap without having to wonder about the underlying implementation. The key properties here are to use CurrentNode and ParentNode, which with some looping can easily provide you with a trail/breadcrumb.

public IEnumerable<SiteMapNode> getBreadCrumb(SiteMapNode root)
{
    var current = SiteMap.CurrentNode;
    var list = new List<SiteMapNode>() { current };

    while (current != null && current.Key != root.Key)
    {
        list.Add(current);
        current = current.ParentNode;
     }

     return list.Reverse();    
}

Now you can easily call this function, which will return you a list af nodes in the order from root until current that you can print out like this

var list = getBreadCrumb(SiteMap.RootNode);
var sb = new StringBuilder();

sb.Append("<ul>");

foreach (var node in list) 
{
   sb.AppendFormat("<li><a href=\"{0}\">{1}</a></li>", node.Url, node.Title);
}

sb.Append("</ul>");

Controls.Add(new LiteralControl(sb.ToString());

And the beauty of this is of course that there is at no point we're depended on C1 here, we're only talking with the standard SiteMap functionality that asp.net provides without caring about the actual implementation. The above code can be reused in any number of asp.net sites on any arbitrary cms system.

The only gotcha is that C1 out-of-box don't have a SiteMap implementation, but you can get one from here http://compositec1contrib.codeplex.com/wikipage?title=SiteMapProvider&referringTitle=Documentation

Mar 26, 2011 at 9:52 PM

Thank you both for the quick replies! I believe those are both great solutions for us. Now just comes down to which implementation will work best. Obviously the Path package is the easiest but I do see merit in being able to decouple it from the system. Especially considering that we would need to rewrite our master pages to fit into the C1 architecture. Burningice... I saw that you did a write up for including master pages. I'll investigate that further to see if it would be more beneficial to go that route with our current schema. However, it's such a mess that on one hand I'm not so sure I'm opposed to just starting from scratch (though reusing the design).

Again, I appreciate both speedy responses. I feel a little stupid not having saw that Path package as I swear that I had carefully gone through all of them before making my post. But it was late in the night (for me at least) so I wasn't on my best game as it were.

Mar 26, 2011 at 10:02 PM

If the site you're migrating is using Masterpages already its definitely worth looking into if that can be reused. And even though most of its a mess, maybe you or your developers are more convenient working in asp.net with masterpages, webcontrols and usercontrols and therefor would be more efficient in redoing it from scratch still with masterpages and not xslt.

Mar 26, 2011 at 10:20 PM

I agree. I'd be fairly comfortable either way. I'll probably setup a couple instances of C1 and try it from both angles to see which 'feels' right including an MS SQL integration as we enjoy about 2-3k hit volume per day. Ultimately, my goal is to hand this over to marketing so they can go wild with it as this would only be for our front end system. I'm trying to wash my hands of the marketing site so I can focus on the back end system full time. But obviously can't do that until I can wrap the front end into a fairly stable/reliable CMS system. So far, just from playing around, I'm finding C1 to be the 'best of breed' from an open source .Net solution standpoint. I have a partner in crime that is trying to steer me towards N2 but I find their interface and workflow to be a little less than desirable though it seems to be fairly solid overall. That said, we are trying our best to make the most thorough evaluation so we can go one way or the other with as much confidence as can be had. 

I appreciate all of the help!

Mar 26, 2011 at 10:38 PM

I guess if you wan't to make marketing-people sit and do stuff on the website just xslt must be the way forward. If they've never been using Visual Studio or that kind of tools it will probably feel more "safe" for them to do everything inside C1 with the xlst editor and visual editor etc. which are pretty error proof and easy to use, also for non-programmers.

Personally i work in a company where a CMS for us, is just that... content management. All design and functionality that is not directly content related is developed and maintained as decoupled from the cms as possible.