November Happy Hour will be moved to Thursday December 5th.

Display page in menus cannot be set to unique value per language

Vote:
 

Unless I am wrong, but it seems like the "Display page in menus" option cannot be set to YES for Unique value per language. If it is possible, then how would you do it without having to add custom code? I couldn't find an option to use this feature.

I would think this feature would be useful because there might be times when you want the page to display in the menu for English, but you don't want the page to display in the menu for Norsk. However, you still would like the page to be available in Norsk and you have a link to the page.

Is this doable or a bug? Or should this be under new feature request?

#36291
Jan 22, 2010 19:58
Vote:
 

Hello Christine! Did you solve this?

#44959
Oct 22, 2010 10:06
Vote:
 

Hi Martin (and Christine)!

I believe You could do it by physically place the page somewhere else (outside the menu), and then use "placeholder"-pages
using the Shortcut "Fetch data from page in EPiServer CMS" in the menu itself.

/johan

#44963
Oct 22, 2010 10:49
Vote:
 

Hi Martin and Johano, I am still having this issue and was not able to find a solution to this yet. I assume I might have to build a custom PageTree if I want to customize which pages display in the menu. The placeholder idea will not work because my issue is that I have a Global English site, and then a United States English site. A certain page is available in the US English site, but not in the Global English site which is my default language. The "display page in menus" is only available in the default language page (Global) and not for all languages, so if I uncheck the box, it will not display for any language. And I need it to display only for US English.

I will keep looking for a way around this. Thanks!

#51111
May 24, 2011 15:48
Vote:
 

I almost have it. First, I created a new property called "DisplayInMenuOverride", type boolean, in my Standard Page (pagetype) as a test. Then, I created a custom filter suggested by this article Custom Filters.

I modified the Visible in menu filter from the article to fit my needs. This is the original filter:

public class FilterVisibleInMenu : IPageFilter
    {
        public FilterVisibleInMenu()
        {
        } 
 
        public void Filter(PageDataCollection pages)
        {
            for (int i = pages.Count - 1; i >= 0; i--)
            {
                if (!pages[i].VisibleInMenu)
                {
                    pages.RemoveAt(i);
                }
            }
        }
 
        public void Filter(object sender, FilterEventArgs e)
        {
            this.Filter(e.Pages);
        }
 
        public bool ShouldFilter(PageData page)
        {
            throw new NotImplementedException();
        }
    }

    

The filter will look for the property "DisplayInMenuOverride", and if it is set to true, then remove the page from the page collection. The problem I am having now is that the GetChildren in MenuList control only goes down 1 level. How do I access ALL children? I would like to go down more than 1 level.

I tested the filter on a top level page, and the filter worked. Now it's just to get the filter to apply to ALL children in the EPiServer:MenuList control. Any suggestions?

#51115
Edited, May 24, 2011 20:03
Vote:
 

I know why it won't get all children from MenuList. I am using a PageList inside of MenuList to display more than one level. I have a dropdown menu, and it goes down 3 levels. The top level is the MenuList, and the other 2 levels are 2 PageLists.

<EPiServer:MenuList ID="Menu" runat="server">
    <HeaderTemplate><ul id="nav"></HeaderTemplate>
    <ItemTemplate>
        <li><EPiServer:Property PropertyName="PageLink" runat="server" />
            <EPiServer:PageList ID="FilterList1" PageLink="<%#Container.CurrentPage.PageLink %>" EnableVisibleInMenu="true" runat="server">
                <HeaderTemplate><ul></HeaderTemplate>
                <ItemTemplate>
                    <li><EPiServer:Property PropertyName="PageLink" runat="server" />
                        <EPiServer:PageList ID="FilterList2" PageLink="<%#Container.CurrentPage.PageLink %>" EnableVisibleInMenu="true" runat="server">
                            <HeaderTemplate><ul></HeaderTemplate>
                            <ItemTemplate><li><EPiServer:Property PropertyName="PageLink" runat="server" /></li></ItemTemplate>
                            <FooterTemplate></ul></FooterTemplate>
                        </EPiServer:PageList>
                    </li>
                </ItemTemplate>
                <FooterTemplate></ul></FooterTemplate>
            </EPiServer:PageList>
        </li>
    </ItemTemplate>
    <SelectedTemplate>
        <li class="selected"><EPiServer:Property PropertyName="PageLink" runat="server" />
            <EPiServer:PageList ID="FilterList3" PageLink="<%#Container.CurrentPage.PageLink %>" EnableVisibleInMenu="true" runat="server">
                <HeaderTemplate><ul></HeaderTemplate>
                <ItemTemplate>
                    <li><EPiServer:Property PropertyName="PageLink" runat="server" />
                        <EPiServer:PageList ID="FilterList4" PageLink="<%#Container.CurrentPage.PageLink %>" EnableVisibleInMenu="true" runat="server">
                            <HeaderTemplate><ul></HeaderTemplate>
                            <ItemTemplate><li><EPiServer:Property PropertyName="PageLink" runat="server" /></li></ItemTemplate>
                            <FooterTemplate></ul></FooterTemplate>
                        </EPiServer:PageList>
                    </li>
                </ItemTemplate>
                <FooterTemplate></ul></FooterTemplate>
            </EPiServer:PageList>
        </li>
    </SelectedTemplate>
    <FooterTemplate></ul></FooterTemplate>
</EPiServer:MenuList>

How would I access the PageList inside of the ItemTemplate in MenuList, so that I can apply the filter using something like:

FilterList1.Filter += new FilterEventHandler((new MainMenuFilter()).Filter);

    

#51151
Edited, May 25, 2011 14:45
Vote:
 

I solved my problem. I applied an OnFilter event on all my PageList controls which will filter and remove all pages that have my custom property "DisplayInMenuOverride" selected. This way I can display Page1 in Us English and hide Page1 in Global English, even though Global English is my default language.

#51154
May 25, 2011 15:49
Vote:
 

Set EnableVisibleInMenu="false" in EPiServer:MenuList, and make this filter:

void uxMenu_Filter(object sender, EPiServer.Filters.FilterEventArgs e)
        {
            for (int i = e.Pages.Count - 1; i >= 0; i--)
            {
                if (!(e.Pages[i] is BasePageType))
                {
                    if (!e.Pages[i].VisibleInMenu)
                        e.Pages.RemoveAt(i);

                    continue;
                }

                var page = e.Pages[i] as BasePageType;

                var visibleInMenuOverride = page.VisibleInMenuOverride;
                if (visibleInMenuOverride)
                    continue;

                if (!visibleInMenuOverride && !e.Pages[i].VisibleInMenu)
                {
                    e.Pages.RemoveAt(i);
                }
            }
        }

#59283
May 29, 2012 13:19
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.