Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preprocess of menus is breaking menus with contrib templates #156

Closed
dxvargas opened this issue Jan 14, 2022 · 3 comments
Closed

Preprocess of menus is breaking menus with contrib templates #156

dxvargas opened this issue Jan 14, 2022 · 3 comments
Assignees

Comments

@dxvargas
Copy link
Member

dxvargas commented Jan 14, 2022

Description

When installing a module having a menu and a template already and using that menu, an error may occur:
InvalidArgumentException: The URI '' is invalid. You must use a valid URI scheme. in Drupal\Core\Url::fromUri() (line 291 of core/lib/Drupal/Core/Url.php).

This is because regular menu templates have items with a title and a link.
But currently the template will not get items with these entries, since after #74 these are replaced with the entries label and path.
Since there is no link entry, fromUri() will break after.
Even without this error, the menu entries won't get displayed correctly, since the template is not getting the expected items title and link.

Steps to reproduce:

This error can be seen following these steps:

  1. Require the contrib module menu_item_extras;
  2. Enable it together with "Menu Item Extras Demo Base";
  3. Place the "Menu Item Extras Demo Menu" block in the section "Navbar branding";
  4. Check the front page, the error will show.

This is because the mentioned menu has already their own templates. When trying to use them, the described problem happens.

@dxvargas
Copy link
Member Author

I propose a simple solution:

The code for adapting the menu to the templates of oe_bootstrap_theme are better placed in a preprocess for the nav pattern, instead of a preprocess of the menus. Like this, only the menus using the nav pattern will be affected by the changes needed in this theme.

@dxvargas
Copy link
Member Author

Another possibility is to adapt the preprocess of the menus to not remove the existing items fields (title, url, attributes), but to only add the needed ones for the BCL templates (label, path, attributes).

@brummbar
Copy link
Contributor

Marking as solved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants