hibbitts-design / grav-theme-quark-open-publishing

A customized version of the Quark theme with Git Sync and 'chromeless' mode support.
http://demo.hibbittsdesign.org/grav-open-publishing-quark/
MIT License
21 stars 13 forks source link

Error displaying custom menu when the menu option is defined in a page #46

Closed pmoreno-rodriguez closed 1 year ago

pmoreno-rodriguez commented 1 year ago

Hello. When the menu option (in the advanced tab in admin) is set to a custom value, the navigation custom menu is not displayed, because in navigation.html.twig the variable for the custom menu is the same as for the menu in admin

If you change this line:

{% for mitem in theme_var('menu') %}

a

{% for mitem in theme_var('custommenu') %}

and in blueprints.yaml 'custommenu' is defined, this problem does not occur.

paulhibbitts commented 1 year ago

Hi @pmoreno-rodriguez , thanks for the issue. I just did a quick test and from what I can see custom menus are displayed as expected. Did you also turn on the display of custom menus (as shown below)?

2022-11-02_14-04-56
pmoreno-rodriguez commented 1 year ago

Hello Paul I have created a custom menu entry like yours and activated it in the theme admin panel.

custom_menu

Now, try to set on any page that appears in the navigation menu, a custom value as indicated below:

custom_menu2

Doing this saves the page to the contact.md file with the following information:

---
title: 'Contact with us'
content:
    items: '@self.modular'
body_classes: modular
menu: Contact
---

In this case the menu variable overrides the menu variable of custom menus.

{% for mitem in theme_var('menu') %}

By doing this, this page (contact) does not show the custom menus.

paulhibbitts commented 1 year ago

Ah, thanks for the additional info @pmoreno-rodriguez . The menu handling re: Macro in Quark (and thus Quark Open Publishing) makes it challenging to handle both custom additional menu items and page overrides. If this is critical, it looks like my other theme Bootstrap4 Open Matter does seem to support this combination based on a quick test I've done here.

If you arrive at an approach that works in all four scenarios (standard menus, custom admin menus, page override menus and custom admin menus + page override menus) please let me know.

Thanks very much, Paul

pmoreno-rodriguez commented 1 year ago

Hi @paulhibbitts.

After doing some tests with a clean installation of the theme and grav, the best option to prevent Grav from overriding the menu variable is to define in the blueprints.yaml file (line 292) of the theme, the variable 'custommenu' or similar and in the navigation.html.twig file (line 35) as {% for mitem in theme_var('custommenu') %}

With this there are no problems with custom menus in the navigation bar.

paulhibbitts commented 1 year ago

Thanks very much @pmoreno-rodriguez , I've made a local test and things look good. Unfortunately this looks like a breaking change, as if an existing setup has custom menus via the Admin they will no longer be displayed unless the corresponding theme config YAML file (storing entires additional menu items) is also updated to use customenu. When doing a fresh install this would not be an issue.

Based on this finding I would suggest you apply these changes to an inherited theme (do you have one setup?) and so this will address the issue for yourself and since it is an inherited theme changes will not be over-written with any future parent theme updates. My Open Publishing Skeleton uses an inherited theme if helpful.

Please let me know your thoughts. Thanks, Paul.

paulhibbitts commented 1 year ago

I am going to close this issue for now, but if I can come up with a non-breaking way to support this scenario I will re-evaluate.