issue with printCustomMenu()?

vincent3569 Member, Translator
edited May 2020 in General support

hi

it seems I have an issue with printCustomMenu() function.

1- in lastest documentation (https://docs.zenphoto.org/1.5.3/function-printCustomMenu.html), I can see that $option can be set to 'list-top'.
If I am not loggued in, it works fine: only top level menu items are shown.
But if I am loggued in, I have an issue : with the menu item with zenpagenewsindex type, I have a sub level displayed in my menu.
to be as clear as possible, with this menu item called "news", if I am on "news list" level, it's OK, but when I chose a news and when I am on "news" level, I have 2 levels on my menu:

  • news
    • news title

example of code with garland
in sidebar.php, I change printCustomMenu($menu, 'list-top', '', "menu-active", "submenu", "menu-active", 2); by printCustomMenu($menu, 'list-top', '', 'active');

when I am on top level of news menu, I have this code:

<div class="menu">
    <ul>
        <li class="menu_galleryindex"><a href="/gallery/" title="gallery">gallery</a></li>
        <li class="menu_zenpagenewsindex active">news</li>
    </ul>
</div>

but If I choose a news item, I have this code:

<div class="menu">
    <ul>
        <li class="menu_galleryindex"><a href="/gallery/" title="gallery">gallery</a></li>
        <li class="menu_zenpagenewsindex -1"><a href="/news/" title="news">news</a>
            <ul class=" menu_zenpagenews">
                <li class="menu_zenpagenews">zpBootstrap – un thème flexible Zenphoto (mis à jour)</li>
            </ul>
        </li>
    </ul>
</div>

you can see the two levels displayed, and also "active" class disapeared.
I don't have this behavior with other type of menu item.

Comments

  • acrylian Administrator, Developer
    edited May 2020

    Without trying myself lacking the time right now: I think what you see is an "invented" sub item. If you are on a news article the "news" link would not stay active because the article is not a sub item in the menu. This the menu "invents" an sub item therefore. The same happens on image pages regarding the album. The custom menu is generally outside of any context and does not know about it as you can mix everything against the actual content structure (e.g. making albums sub menu entries of albums that are not their parent even if that is confusing) .This "invention" is the only exception as there is no menu item for single images or single articles.

    You have to hide that via CSS currently. I am not sure why this would make a difference if loggedin or not right now. Perhaps that is an unpublished article?

    I don't remember why it was done this way anymore. There might be a better way and it is on the long list of things to do…

  • acrylian Administrator, Developer

    I can confirm that this is the "Invented" item I mentioned above. You need to add theme CSS to hide this sublist by the class name attached, e.g. .menu_zenpagenewsindex.menu_active > submenu { display: none; }
    As said in the future this might be solved better without actually printing that "invented" item as the menu_manager is meant to be internally reworked anyway. But not now.

  • vincent3569 Member, Translator
    edited May 2020

    very hard to understand the behavior of this plugin and how works printCustomMenu().
    why css class ('active' in my example) disapears on top level when I am on a sub level?
    in a menu tree, all items of the selected branch should active, don't you think?

  • acrylian Administrator, Developer
    edited May 2020

    Yes, generally I agree that this would make sense. As said the plugin is on the list to be reworked in the future anyway.

  • vincent3569 Member, Translator

    I have to code a workaround in my theme to manage this plugin and I really don't like it.
    I think the main problem is that the classes in the function parameters are not applied correctly to menu items.
    this means that the css rules cannot be applied correctly (basically, I need a menu item with an 'active' css rule to highlight this menu item).

Sign In or Register to comment.