Base solution for your next web application
Ends in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

SubItem menu (FrontEndNavigationProvider) #1768


User avatar
0
benjamim created

I can not put sub-items on the front site menu (FrontEndNavigationProvider). I'm putting the same name all the items, this leaves all selected. I need only the parent item and the selected item be selected be marked

.AddItem(new MenuItemDefinition(
                    "Frontend.Solucao",
                    new FixedLocalizableString("Solução")
                    ).AddItem(new MenuItemDefinition(
                                    "Frontend.Solucao",
                                    new FixedLocalizableString("Guarda Móveis"),
                                    url: "/self-storage/guarda-moveis")
                                ).AddItem(new MenuItemDefinition(
                                    "Frontend.Solucao",
                                    new FixedLocalizableString("Guarda Documentos"),
                                    url: "/self-storage/guarda-documentos")
                                ).AddItem(new MenuItemDefinition(
                                    "Frontend.Solucao",
                                    new FixedLocalizableString("Guarda Estoque"),
                                    url: "/self-storage/guarda-estoque-para-empresas")
                                ).AddItem(new MenuItemDefinition(
                                    "Frontend.Solucao",
                                    new FixedLocalizableString("Guarda Volumes"),
                                    url: "/self-storage/guarda-volumes")
                                ).AddItem(new MenuItemDefinition(
                                    "Frontend.Solucao",
                                    new FixedLocalizableString("Depósito Privativo"),
                                    url: "/self-storage/deposito-privativo")
                                ).AddItem(new MenuItemDefinition(
                                    "Frontend.Solucao",
                                    new FixedLocalizableString("Galpões Modulares"),
                                    url: "/self-storage/galpoes-modulares")
                                 ).AddItem(new MenuItemDefinition(
                                    "Frontend.Solucao",
                                    new FixedLocalizableString("Guarda Volumes"),
                                    url: "/self-storage/guarde-objetos-reformas-ampliacoes")
                                 ).AddItem(new MenuItemDefinition(
                                    "Frontend.Solucao",
                                    new FixedLocalizableString("Guarda Volumes 2"),
                                    url: "/self-storage/startups-pme")
                                 ))


3 Answer(s)
  • User Avatar
    0
    hikalkan created
    Support Team

    Hi,

    menu name should be unique (you named 'Frontend.Solucao' for all). Can you try tof fix it?

  • User Avatar
    0
    benjamim created

    Yes, but dont set primary node

    .AddItem(new MenuItemDefinition(
                        "Frontend.Solucao1",
                        new FixedLocalizableString("Solução")
                        ).AddItem(new MenuItemDefinition(
                                        "Frontend.Solucao2",
                                        new FixedLocalizableString("Guarda Móveis"),
                                        url: "/self-storage/guarda-moveis")
                                    ).AddItem(new MenuItemDefinition(
                                        "Frontend.Solucao3",
                                        new FixedLocalizableString("Guarda Documentos"),
                                        url: "/self-storage/guarda-documentos")
                                    ).AddItem(new MenuItemDefinition(
                                        "Frontend.Solucao4",
                                        new FixedLocalizableString("Guarda Estoque"),
                                        url: "/self-storage/guarda-estoque-para-empresas")
                                    ).AddItem(new MenuItemDefinition(
                                        "Frontend.Solucao5",
                                        new FixedLocalizableString("Guarda Volumes"),
                                        url: "/self-storage/guarda-volumes")
                                    ).AddItem(new MenuItemDefinition(
                                        "Frontend.Solucao6",
                                        new FixedLocalizableString("Depósito Privativo"),
                                        url: "/self-storage/deposito-privativo")
                                    ).AddItem(new MenuItemDefinition(
                                        "Frontend.Solucao7",
                                        new FixedLocalizableString("Galpões Modulares"),
                                        url: "/self-storage/galpoes-modulares")
                                     ).AddItem(new MenuItemDefinition(
                                        "Frontend.Solucao8",
                                        new FixedLocalizableString("Guarda Volumes"),
                                        url: "/self-storage/guarde-objetos-reformas-ampliacoes")
                                     ).AddItem(new MenuItemDefinition(
                                        "Frontend.Solucao9",
                                        new FixedLocalizableString("Guarda Volumes 2"),
                                        url: "/self-storage/startups-pme")
                                     ))
    

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    You can implement a custom solution like this. name your main menu item from "Frontend.Solucao1" to "Frontend.Solucao" and in _Header.cshtml instead of checking the equality of currentPageName like this

    menuItem.Name == Model.CurrentPageName ? "active" : ""
    

    change it to

    menuItem.Name == Model.CurrentPageName || Model.CurrentPageName.StartsWith(menuItem.Name) ? "active" : ""
    

    In this way both submenuItem and parent menu item will be selected. But you have to be careful when naming your menu items according to this logic.

    And of course you have to set ViewBag.CurrentPageName to page name in your cshtml files.