Jawad Khan

Jawad's Lodge - The willingness to torture yourself before others is what makes a developer truly a unique breed.
posts - 45, comments - 167, trackbacks - 148

My Links

News

Archives

Post Categories

Image Galleries

MCMS 101 ... How to get List of Child Channels Name and Url for Navigation control ...

I am working on a more complex class that will have an option to return deep Hierarchy and will have different options like get Hierierchy for only 2 level deep channels etc. Mean while I wanted to put the simplest solution to get the list with Display Name and Url for new comers to MCMS ...to keep it completely simple I am not including any Error handling which you should including your code ...

    For this example lets assume you have you left Navigation defined in SiteManager as follows Channel the Root Channel of MCMS, MySite is the Name of your website, en-CA is you are localizing you website then usually you will have english french etc channel, LeftNavigation a Channel name that contains underneath all the channels that represent the Options that will be displayed in Left Navigation.

   I will display the list in simple Anchor tag separated by BR

    using Microsoft.ContentManagement.Publishing;

    using System.Text;

    private CmsHttpContext ctx = CmsHttpContext.Current;

   Channel startingChannel = (Channel)ctx.Searches.GetByPath(“/Channels/MySite/en-CA/LeftNavigation“);

   StringBuilder sb = new StringBuilder();

   foreach(Channel ch in startingChannel.Channels)
   {

            sb.Append(“<a href='“);
            sb.Append(ch.Url);
            sb.Append(“'>“);
            sb.Append(ch.DisplayName);
            sb.Append(“</a><BR>“);
   }

   Now you can do sb.ToString() to get the HTML to display the Left Navigation anchor menu.
   Off course you can use it for TopNavigation or some other similar functionality.

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Print | posted on Friday, May 13, 2005 2:21 PM | Filed Under [ Microsoft Content Management Server ]

Feedback

Gravatar

# re: MCMS 101 ... How to get List of Child Channels Name and Url for Navigation control ...

thanks this was exactly what I have been looking for.
6/7/2005 11:14 AM | gary
Gravatar

# re: MCMS 101 ... How to get List of Child Channels Name and Url for Navigation control ...

Thanks sir, you save my live :)
12/19/2008 7:39 PM | tio
Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification:
 
 

Powered by: