Sitefinity ASP.NET CMS

Not answered Simple Menu Control?

Feed from this thread
  • Jay Jay's avatar

    Posted on Feb 23, 2009 (permalink)

    I'm trying to create a very simple left-side menu and having more problems than I would've thought.  I have everything controlled by CSS so all I need the control to output is a bulleted list like this:

                    <ul>
                        <li><a href="">Who We Are</a></li>
                        <li><a href="">Our Work</a></li>
                        <li><a class="selected" href="">Frequently Asked Questions</a></li>
                    </ul>

    I'm using a Site Menu control and I've turned off the skin and added my "selected" class which gets me 90% there.  No matter what page I'm on though, the first link ALWAYS has the selected class.  I can't figure out how to turn it off.

    I have my pages like this:
    About Us (page group)
      - Who We are
      - Our Work
      - Frequently Asked Questions

    Does the first link always being selectedhave something to do with it being the first page in a page group?

    I also have:
    StartingNodeOffset: 0
    ShowStartingNode: False
    StartFromCurrentNode: False
    StartingNodeUrl: ~/about-us.aspx (which is the name of the page group)

    How can I make sure that the is only applied to the actual current page?
    Any help will be appreciated.

    Reply

  • Jay Jay's avatar

    Posted on Feb 25, 2009 (permalink)

    I did some testing and the reason my first item always gets the selected class is definitely because it's the first page in a page group.  Is there any way around that?
    Perhaps some way to override that function?  Any help would be appreciated.

    Reply

  • Telerik Admin admin's avatar

    Posted on Feb 25, 2009 (permalink)

    Hi Jay,

    You could try applying different styles for the grup and the first page modifying the code behind of the menu. Below is a sample:

     public void RadMenu1_ItemDataBound(object sender, RadMenuEventArgs e) 
        { 
            RadMenu radMenu = (RadMenu)sender; 
            CmsSiteMapNode node = e.Item.DataItem as CmsSiteMapNode; 
            if (node != null && SiteMap.CurrentNode == node) 
            { 
                if (node.CmsPage.PageType == CmsPageType.Group && radMenu.Items.Count > e.Item.Index) 
                    radMenu.Items[e.Item.Index + 1].CssClass = "myclass"
                else 
                    e.Item.CssClass = "myclass"

    I hope this helps.

    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.

    Reply

  • Jay Jay's avatar

    Posted on Feb 26, 2009 (permalink)

    Thanks so much.  You guys have the best support team of any vendor I've ever worked with.  For anyone else who might be interested.  Here is my final function with the code Ivan sent added to it.

        public void RadMenu1_ItemDataBound(object sender, RadMenuEventArgs e) 
        { 
            if (this.hideUrlForGroupPages) 
            { 
                CmsSiteMapNode node = e.Item.DataItem as CmsSiteMapNode; 
                if (node != null && node.PageType == CmsPageType.Group) 
                { 
                    e.Item.NavigateUrl = ""
                } 
            } 
     
            CmsSiteMapNode currentNode = SiteMap.CurrentNode as CmsSiteMapNode; 
            if (currentNode != null && currentNode.ParentNode != null
            { 
                while (currentNode.ParentNode != SiteMap.RootNode) 
                { 
                    RadMenuItem item2 = this.RadMenu1.FindItemByUrl(this.ResolveUrl(currentNode.Url)); 
                    if (item2 != null
                        item2.CssClass = this.selectedItemCssClass; 
                    currentNode = currentNode.ParentNode as CmsSiteMapNode; 
                } 
     
                RadMenuItem item = this.RadMenu1.FindItemByUrl(this.ResolveUrl(currentNode.Url)); 
                if (item != null
                { 
                    if (currentNode.CmsPage.PageType != CmsPageType.Group) 
                    { 
                        // here you can set the style for the top-level item    
                        item.CssClass = this.selectedItemCssClass; 
                    } 
                } 
            }  
        } 

    Reply

About Telerik

Telerik, the publisher of Sitefinity CMS, is a leading vendor of ASP.NET AJAX, ASP.NET MVC, Silverlight, WinForms and WPF controls and components, as well as .NET Reporting and .NET ORMTFSCode Analysis and Web Application Testing tools. Building on its solid expertise in interface development and Microsoft technologies, Telerik helps customers build applications with unparalleled richness, responsiveness and interactivity. Created with passion, Telerik products help thousands of developers every day to be more productive and deliver reliable applications under budget and on time. Read more about Telerik

Copyright © 2002-2010 Telerik. All rights reserved. Powered by Sitefinity