Try our conversational search powered by Generative AI!

Why whenever i click on newly added menu item, it somehow navigates to its child menu url instead of showing other child menu's item?

Ash
Ash
Vote:
 

https://world.episerver.com/documentation/developer-guides/CMS/user-interface/extending-the-navigation/adding-and-configuring-menu-items/

I use the code form the above link present in example 4(New global menu section.).

I just only changed the url of the child menu's item and it is not working as it is showing in example 4 view.

#218404
Mar 12, 2020 11:20
Vote:
 

hi, your exact code fragment in use would be helpful here.

#218408
Mar 12, 2020 11:38
Ash
Vote:
 
 [MenuProvider]
    public class EHAppsMenuProvider : IMenuProvider
    {
        const string MenuPath = MenuPaths.Global + "/apps";


        public IEnumerable<MenuItem> GetMenuItems()
        {
            var menuItems = new List<MenuItem>();

            // Add Emergency Text Main & Subb menus 
            menuItems.Add(new SectionMenuItem("Apps", MenuPath)
            {
                SortIndex = SortIndex.Last + 10,
                IsAvailable = (request) => PrincipalInfo.HasEditAccess
            });

            menuItems.Add(new UrlMenuItem("Text", MenuPath + "/Text", UriSupport.ResolveUrlFromUIAsRelativeOrAbsolute("/Text/Index"))
            {
                SortIndex = 1
            });

            return menuItems;
        }
    }
#218411
Mar 12, 2020 11:47
Vote:
 

if you inspect what you get back from this UriSupport.ResolveUrlFromUIAsRelativeOrAbsolute("/Text/Index")?

#218414
Mar 12, 2020 11:58
Ash
Vote:
 

No, it is not about "UriSupport.ResolveUrlFromUIAsRelativeOrAbsolute".

Actually i was getting even the same result without this code.

I am using this before:-

menuItems.Add(new UrlMenuItem("Text", MenuPath + "/Text", "/Text/Index")

#218415
Mar 12, 2020 12:05
Vote:
 

but what you experience now when you changed urls for the child menu items? 404? or menu is not shown at all? what are effects? asking because I have working example..

#218416
Mar 12, 2020 12:18
Ash
Vote:
 

i am saying that i want show my all child menu items
but whenever i click on the newly added parent menu then
it navigates to the first child menu's url and i couldn't see the other child menu item


If you try the orginal code from the link i shared with you then it is working fine
when i click on the parent menu item then first it show it's child menu's item.

#218417
Mar 12, 2020 12:26
Vote:
 

oh, ok understood now. opening 1st child menu item is by design. this is sort of like landing page for the module. if I understood you correctly then what might be missing in your case is menu rendering in the "Apps/Text/Index" view. Have you included Html.CreatePlatformNavigationMenu() in your markup?

#218419
Mar 12, 2020 13:05
Ash
Vote:
 

Ok thanks 

I just only want to know why it is happening in the latest version .

But as you are saying it is by design then it will be ok

#218420
Mar 12, 2020 13:10
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.