If you have questions about using mojoPortal, you can post them here.
You may want to first review our site administration documentation to see if your question is answered there.
Hi,
Let's say I have a site with a menu and sub-menu displayed in the header. When I access a page, say:
Level 1 > Level 2 > My current page
The "Level 2" button in my menu is highlighted when I am on "My current page". However if "My current page" is not set to be included in the menu, then the Level 2 (and Level 1) menu options will not be highlighted.
Is there a workaround so the the correct level stays highlighted/active in the menu even if the sub-page is not included in the menu?
I'm not aware of any method to force highlighting in the menu, but as a workaround, you could include breadcrumbs in the layout.master file of your skin.
Jamie
Thanks Jamie. I'm already using breadcrumbs, so the visitor is not completely lost, but it would be way better if the sub-menu would also indicate in which section he is, even if the current page is not included in the menu.
Its just the way the menu control works, it would highlight if it had active child items but since the child is not included in the menu the menu does not know it has an active child item. No easy solution comes to mind.
I'm not so sure whether it's a good idea or not, but placing following code in SiteMenu.ascx.cs will do the job
menuItem = menu.FindItem(valuePath); //If the page is not Included In Menu, the above line of code wont work, following code is workaround for it //========= if (menuItem == null) { if (!string.IsNullOrWhiteSpace(valuePath)) { int lastSeperatorIndex = valuePath.LastIndexOf(menu.PathSeparator); while (lastSeperatorIndex > 0) { valuePath = valuePath.Substring(0, lastSeperatorIndex); menuItem = menu.FindItem(valuePath); if (menuItem != null) break; lastSeperatorIndex = valuePath.LastIndexOf(menu.PathSeparator); } } } //=========
Thanks for this, it looks like a good solution to me. But can you be more specific about where it goes, ie what line number before and after this code?
Thanks,
Joe
Hi Joe
As of version 2.3.6.2, I placed this code after the line number 413.
406: if (!didSelect) 407: { 408: valuePath = SiteUtils.GetActivePageValuePath(siteMapDataSource.Provider.RootNode, startingNodeOffset);
409:
410: if (valuePath.Length > 0)
411: { 412: MenuItem menuItem; 413: menuItem = menu.FindItem(valuePath);
Thanks! I will make this change.
Best,
I've downloaded version 2.3.6.5 with the change mentioned above but used function IsNullOrWhiteSpace doesn't work with dot.net 3.5, and solution doesn't compile in that framework.
So I changed it with similar one (MS documentation):
!(String.IsNullOrEmpty(valuePath) || valuePath.Trim().Length == 0)
Giuseppe
This is already fixed in the source code repository, I encountered this myself when packaging the 3.5 .NET packages for the new 2.3.6.6 release.