visible page in menu programmtically while it is set to false from settings in edit mode

Vote:
 

How can I show a page in menu programmatically while it is set to false(visible in menu) in settings of edit mode?

#72887
Jul 02, 2013 12:18
Vote:
 

How are you rendering your Menu?

If you're using the EPiServer:MenuList Web Control you can add EnableVisibleInMenu="false" to include pages that have visible in menu set to false.

#72898
Jul 02, 2013 14:28
Vote:
 

Yes, it's really depends on how you are rendering the menu.

If you are constructing it manually, you can use filters and properties (this could be useful found in Alloy MVC sample):

public static IEnumerable<T> FilterForDisplay<T>(this IEnumerable<T> contents, bool requirePageTemplate = false, bool requireVisibleInMenu = false)
        where T : IContent
{
    var accessFilter = new FilterAccess();
    var publishedFilter = new FilterPublished(ServiceLocator.Current.GetInstance<IContentRepository>());
    contents = contents.Where(x => !publishedFilter.ShouldFilter(x) && !accessFilter.ShouldFilter(x));
    if (requirePageTemplate)
    {
        var templateFilter = ServiceLocator.Current.GetInstance<FilterTemplate>();
        templateFilter.TemplateTypeCategories = TemplateTypeCategories.Page;
        contents = contents.Where(x => !templateFilter.ShouldFilter(x));
    }
    if (requireVisibleInMenu)
    {
        contents = contents.Where(x => VisibleInMenu(x));
    }
    return contents;
}

private static bool VisibleInMenu(IContent content)
{
    var page = content as PageData;
    if (page == null)
    {
        return true;
    }
    return page.VisibleInMenu;
}

    

 

#72901
Jul 02, 2013 14:41
Vote:
 

I am using Episerver.PageTree control to render the menu..

#73458
Jul 23, 2013 8:25
Vote:
 

If you mean the web control <EPiServer:PageTree />

Try to add EnableVisibleInMenu="false"

#73459
Jul 23, 2013 10:07
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.