Geeks With Blogs
Jawad Khan Jawad's Lodge - The willingness to torture yourself before others is what makes a developer truly a unique breed.

I have seem a few Breadcrumb Controls for Microsoft Content Management System that display the Hierarchy/Path of the current Posting(page). While designing a MCMS 2002 site the site-map is laid out in such a way that the Navigation of the site is made simple and its easily accessible by the MCMS API calls.Its common to have a Hierarchy like this 
/Channels/RetailerSite/en-CA/LeftNavigation/OurProducts/Computers and
/Channels/RetailerSite/en-CA/LeftNavigation/ThirdPartyProducts/WebCams.

  In your breadcrumb you would like to Skip OurProduct and Left Navigation Channels (Folder) as well as Channels Channel(Folder) itself. Further you might want to show the Display name of the Channel rather then the name of the Channel which is more meaningful to the end users.
The Breadcrumb should look like

   Retailer Site > English > Computers
   Retailer Site > English . WebCams

To accomplish the above goal we could use a property named Important Flag on the Channel. The following Breadcrumb code check if the Important Flag is set on the Channel from SiteManager or Web Author. Only those Channels that have this flag set appears in the Breadcrumb Hierarchy of the current Posting(WebPage) ....

Here is the Code .... You can add it into ASP.Net User Control. All you have to do is add a Label to the User control and insert the following code in the code behind file .....

 using System.Text;
 using System.Collections ;
 using Microsoft.ContentManagement.Publishing ;

  private void ProcessBreadCrumb()
  {
     StringBuilder sb = new StringBuilder ();
     Channel processedChannel = CmsHttpContext.Current.Channel;
     Stack breadCrumbChannels = new Stack();
    do
    {
          if (processedChannel.IsImportant)
         {
             breadCrumbChannels.Push(processedChannel);
          }
          processedChannel = processedChannel.Parent ;
      } while (!processedChannel.Parent.IsRoot);
           
   int totalChannels = breadCrumbChannels.Count;
   Channel ch = null;
   for(int i=1; i <= totalChannels; i++)
   {
            ch = (Channel)breadCrumbChannels.Pop ();
            sb.Append ("<a class='BreadCrumbAnchor' href='");
            sb.Append (ch.Url );
            sb.Append ("'>");
            sb.Append (ch.DisplayName );
            if ( i < totalChannels)
           {
              sb.Append ("&nbsp;&nbsp;&nbsp;");
              sb.Append (">");
              sb.Append ("&nbsp;");
            }
           sb.Append ("</a>");
       }
         this.lblBreadCrumb.Text = sb.ToString (); // ASP.Net label control in the User Control ...
      }

Posted on Wednesday, June 1, 2005 11:36 PM Microsoft Content Management Server | Back to top


Comments on this post: MCMS 101 - Creating a BreadCrump Control that skips undesired Channels (Folders)

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Jawad Khan | Powered by: GeeksWithBlogs.net