2

Resolved

Media Library : Following rev 6913 -> First levels of Admin Sub Menu have disappeared

description

I finally opened it as an issue because the Setting Admin Menu has also lost it General Sub-Menu....
Original discussion https://orchard.codeplex.com/discussions/441043
This code was previously displaying an Admin SubMenu named Currencies.
Now it has disappeared, I get the admin page directly clicking on the parent Menu.
public class CurrenciesAdminMenu : INavigationProvider {
    public string MenuName {
        get { return "admin"; }
    }

    public CurrenciesAdminMenu() {
        T = NullLocalizer.Instance;
    }

    private Localizer T { get; set; }

    public void GetNavigation(NavigationBuilder builder) {
        builder
            .AddImageSet("datwendo-commerce")
            .Add(item => item
                .Caption(T("Datwendo Commerce"))
                .Position("3")
                .LinkToFirstChild(true)

                .Add(subItem => subItem
                    .Caption(T("Currencies"))
                    .Position("3.1")
                    .Action("Index", "CurrenciesAdmin", new { area = "Datwendo.Commerce" })
                )
            );
    }
}
}
Is it normal or a new bug ? I see no change on my side, not workingon core navigation components of Orchard ?

comments

CSADNT wrote Apr 24, 2013 at 10:37 AM

Digging further, it appears that the change is in Menu.cshtml of TheAdmin\Views

The change drive to not display the firt item, I don't understand why, its breaking all the visual Menu of some sites
 <ul class="menuItems">                
@{ var first = true;}    
                @foreach (var secondLevelMenuItem in secondLevelMenuItems.Where(menuItem => !menuItem.LocalNav)) {
                    if (first && firstLevelMenuItem.LinkToFirstChild) {
                        first = false;
                        continue;
                    }
                    
previously it was
 <ul class="menuItems">
                @foreach (var secondLevelMenuItem in secondLevelMenuItems.Where(menuItem => !menuItem.LocalNav)) {
                    string secondLevelTextHint = secondLevelMenuItem.Text.TextHint;
                    var firstOfTheThird = ((IEnumerable<dynamic>)secondLevelMenuItem.Items).FirstOrDefault();

CSADNT wrote Jul 24, 2013 at 10:01 AM

I still don't understand why this has not been re-established, plenty custom Admin module menus are now inadapted:
When you have a upper level Menu, it resumes the content of its sub levels ? When you click on 'Commerce', should you see the currencies because the currencies sub menu has been crunched by the bad code ?
Not happy with this and also martians certainly throwing stones on earth.

A solution should be to have, as done in MS CRM v4 and Outlook a page menu associated with the upper level menu and presenting the submenus as a grid of buttons.... should time expend ...

sfmskywalker wrote Jul 31, 2013 at 7:07 AM

The behavior I witnessed using above AdminMenu actually seems to be correct:
  • Since "LinkToFirstChild" is set to "true", and there's only 1 sub menu item, there's no reason to render the sub menu item, as the main menu item will already point to that URL.
If you did want to render the sub menu item, simply set LinkToFirstMenuItem to false.

If you are still seeing an issue, please comment and we'll reopen the ticket.

** Closed by sfmskywalker 07/30/2013 11:07PM

CSADNT wrote Jul 31, 2013 at 8:09 AM

I don't agree, the Admin Menu level in 1.6 is different from the one in 1.7, many first level enus were differents from their actual look, this must be discussed and not assume by a sole person !

CSADNT wrote Jul 31, 2013 at 8:12 AM

Start with the Settings Admin menu in 1.6 versus 1.7

CSADNT wrote Jul 31, 2013 at 8:32 AM

This is hidding the 'first first level' menu item even when you have several of them, this is not logical.

CSADNT wrote Jul 31, 2013 at 9:34 AM

Skype, have a look here, the image displayed is no more this one with 1.7
http://skywalkersoftwaredevelopment.net/blog/writing-an-orchard-webshop-module-from-scratch-part-10

CSADNT wrote Aug 2, 2013 at 11:08 AM

Solved this problem with a Page Menu module which associates a Page to the upper Menu level.
Just have to insert a sub menu calling the pagemenu to have a page displaying the sub-menus when clicking parent
(https://bitbucket.org/csurieux/datwendo.pagemenu)

So before
        public void GetNavigation(NavigationBuilder builder) {
            builder
                .AddImageSet("datwendo-commerce")
                .Add(item => item
                    .Caption(T("Datwendo Commerce"))
                    .Position("3")
                    .LinkToFirstChild(false)
                    .Add(subItem => subItem
                        .Caption(T("Currencies"))
                        .Position("3.1")
                        .Action("Index", "CurrenciesAdmin", new { area = "Datwendo.Commerce" }).Permission(Permissions.ManageECommerce)
                    )
                );
        }
and after
        public void GetNavigation(NavigationBuilder builder) {
            builder
                .AddImageSet("datwendo-commerce")
                .Add(item => item
                    .Caption(T("Datwendo Commerce"))
                    .Position("3")
                    .LinkToFirstChild(false)
                    .Add(subItem => subItem
                        .Caption(T("PageMenu")) // only PageMenu admitted here
                        .Position("3.0")
                        .Action("Index", "PageMenuAdmin", new { area = "Datwendo.PageMenu", MenuCaption = "Datwendo Commerce" }).Permission(Permissions.ManageECommerce)
                    )
                    .Add(subItem => subItem
                        .Caption(T("Currencies"))
                        .Position("3.1")
                        .Action("Index", "CurrenciesAdmin", new { area = "Datwendo.Commerce" }).Permission(Permissions.ManageECommerce)
                    )
                );
        }

sfmskywalker wrote Aug 7, 2013 at 10:01 AM

An update was just pushed that will render the first second level item if you set LinkToFirstChild to false. I tested it with the CurrenciesAdminMenu code snippet (changing LinkToFirstChild to false). If you still want to have the first level item (Datwendo Commerce) link to a page, e.g. the first child item's url, you can set its Action to the same thing. This kind of defeats the purpose of the LinkToFirstChild being set to false, but apparently it was decided that if the first level menu item links to its first and only child menu item, it is superfluous to render that child. We could start a new discussion whether we should add another option, such as "RenderFirstItem", which would default to "false", but can be set to "true" so that the first child will render regardless of the 1st level item linking to its first child.

sfmskywalker wrote Aug 7, 2013 at 10:02 AM

Fixed in changeset 3b9bbb2b9a3a4e12fa07f0a2da679a314d52107d

sfmskywalker wrote Aug 7, 2013 at 10:11 AM

Fixed in changeset f59a0712510d2e25a3a689d01517d5e889a047db

CSADNT wrote Aug 7, 2013 at 11:54 AM

Hope this will not again break my last code.
But yes a discussion or clear documentation should be propagated to Orchard Documentation for menus...