Google Analytics

Saturday, October 23, 2010

Absolute Left-hand Navigation in Page Layouts

I've chosen this topic because when I first received the requirement for this, I thought it'd be tough or at the very least, messy.  It turned out to be extremely simple and clean.

Business owner, "When I'm navigating my particular sub-site, I always want the left-hand navigation to begin with the first node in my sub-site.  This should always be the case no matter how deep I get in my sub-site."

Example Site Structure:
Root Site Collection
   Busines Owner's Sub-Site
   (Nav should begin here no matter which page we're actually on)
      Pages
      A Lower Sub-Site
         Pages
         An Even Lower Sub-Site
            Pages

To fulfill this requirement, it's merely a matter of configuring your SiteMapDataSource (or PortalSiteMapDataSource) properly.  We need to key on two properties, StartFromCurrentNode and StartingNodeOffset.

In this case, we'd want StartFromCurrentNode = false and StartingNodeOffset = 1.  The tells our SiteMapDataSource to always start at the Root Site Collection node then offset one node down.

The only downfall I can see here is you're going to have to train the business owner to use the right page layouts, but they have probably already asked for special branding anyway.

References:
SiteMapDataSource.StartFromCurrentNode
SiteMapDataSource.StartingNodeOffset

No comments:

Post a Comment