+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Correct arguments for a custom MegaMenu navigation

Correct arguments for a custom MegaMenu navigation

3 posts, 0 answered
  1. Faramarz
    Faramarz avatar
    5 posts
    Registered:
    06 Aug 2012
    20 Jun 2013
    Link to this post
    I am working on a custom MegaMenu for my website navigation but I don't think I am using correct arguments.

    As you know, Sitefinity pages can have five different statuses:

    1) Published and Show in Navigation
    2) Published but don't show in Navigation
    3) Unpublished
    4) Use this page only to group other pages
    5) Use this page to redirect to another page

    With the code below, I have managed to take care of the status list above for my pages. (I don't want unpublished pages and those that are set to "Not to show in navigation" and those pages that are used only to group other pages to show up in my dropdown menu).  

    So far everything looks good but I get an error when I use one of those hidden pages (those that are set "Not to show in navigation") to display the content of my single item widgets.  For example, when I am using the "News" widget, if I choose "Selected existing page.." for displaying my single item detail page, and if the selected page is set not to show in navigation, then I get an error. 

    What are the correct arguments to use for my menu?  I think my problem with this custom menu will be fixed if I use Radmenu's arguments, because when I choose not to use the custom MegaMenu, then Radmenu doesn't give me that error.

    This is the code I am using and I am using Sitefinity 6.0:

    void MegaMenuTemplate_IsNodeAccessible(object sender, IsAccessibleArgs e)
    {
        var pageNode = e.Node as PageSiteNode;
        if (pageNode != null)
        {
            if ((String.IsNullOrEmpty(pageNode.Title) && // used in multilingual; captures the cases of synced, split, and group pages
                   pageNode.Id != SiteInitializer.CurrentFrontendRootNodeId)) // ensures that the root node is not hidden and thus all other pages
            {
                e.IsAccessible = false;
                return;
            }
     
            //The page should be hidden if it is a group page and it has no child pages.
            if (pageNode.IsGroupPage && pageNode.ChildNodes.Count < 1)
            {
                e.IsAccessible = false;
                return;
            }
     
            //Added for preventing the unpublished pages to show in navigation
            if (pageNode.ShowInNavigation == false)
            {
                e.IsAccessible = false;
                return;
            }
     
            if (pageNode.Title != "Pages" && pageNode.Status != Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live)
            {
                e.IsAccessible = false;
                return;
            }
        }
        else
        {
            throw new NotSupportedException("The supported types are 'TaxonSiteNode' or 'PageSiteNode'.");
        }
     
        e.IsAccessible = true;
    }

    Thank you in advance.
  2. Jen Peleva
    Jen Peleva avatar
    568 posts
    Registered:
    10 Nov 2016
    25 Jun 2013
    Link to this post
    Hello Faramarz,

     I have already responded to you in the support ticket. Please try the control and let me know if it works for you! :)

    Regards,
    Jen Peleva
    Telerik
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Faramarz
    Faramarz avatar
    5 posts
    Registered:
    06 Aug 2012
    25 Jun 2013 in reply to Jen Peleva
    Link to this post
    Jen, I really appreciate it.  It works :)
3 posts, 0 answered