Document to only add menu items via a menu such as "Main navigation", not Views

Created on 3 December 2023, 12 months ago
Updated 13 December 2023, 11 months ago

Problem/Motivation

If you have a View, and add a menu item via a view (Level 2 below) and arrange the item in a hierarchy for example in the "Main navigation" menu, the menu hierarchy is not transfered and the menu item is shown as a top menu item, when it should be under another menu item.

Level 1
    Level 2

Shown like this:

Level 1
Level 2

Steps to reproduce

Proposed resolution

Document the workaround in the README and on the project page

Don't define any menu items in the view, but only under for example "Main navigation"(/admin/structure/menu/manage/main). Then the structure can be both exported and imported.

Remaining tasks

At some point in the future, Views menu items may get supported, a follow up issue should be created for this.

User interface changes

API changes

Data model changes

📌 Task
Status

Fixed

Version

2.0

Component

Documentation

Created by

🇩🇰Denmark ressa Copenhagen

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @ressa
  • 🇩🇰Denmark ressa Copenhagen
  • 🇷🇴Romania bbu23

    Hi ressa,

    Thank you for reporting this issue.

    Yes indeed, I am aware of this. Now, the thing is that we are deleting the whole structure before import. So, the Views would lose the parent upon import. I don't remember if Views are creating MenuLinkContent items or not, but even so, the parent will have a new ID & UUID and Views is not aware of that.

    At the moment, I have no plans on managing that case, since the workaround exists and it is not a blocker. Indeed, it's much nicer to have it there, same situation with nodes and the their menu setting. Though this could be tied up with a potential change in the way we import/export menus, but that's a future plan that I have to think about.

    I have a similar situation with Taxonomy Menu, but in this particular case I know for sure that the taxonomy menu items are not MenuLinkContent, and I have a separate drush command that fixes the parent.

    I will come back to this in the future, but for now I'll leave it open.

  • Status changed to Needs review 11 months ago
  • 🇩🇰Denmark ressa Copenhagen

    Thanks for a fast reply @bbu23, and for clarifying why this happens. Great that you are aware of this, and I agree that a workaround exists and works fine. A more elaborate solution could be made in the future.

    Since adding menu items via Views is very common, I think we should document it right away in the README and on the project page, to save people from wasting time, failing on import, experimenting and debugging, and finally understanding why it happens.

    Since there is now a proposed solution, the challenge of supporting View menu items can be handled in a follow up issue, whereas this issue is now actionable, and it is an annoying bug for the uninitiated, so changing status to Normal.

  • 🇩🇰Denmark ressa Copenhagen

    I created a follow up issue.

  • 🇷🇴Romania bbu23

    Sounds good, ressa. Thanks.

  • 🇩🇰Denmark ressa Copenhagen

    You're welcome, and feel free to review the MR here, when you have time.

  • 🇷🇴Romania bbu23

    Hi ressa, I quickly looked at the MR. I left 1 tiny comment, the rest should be fine. Thanks

  • 🇷🇴Romania bbu23

    And I'm not sure if we should link the related issue in the README or not (regarding Views). I'll leave that up to you. (close to line 31)

  • 🇩🇰Denmark ressa Copenhagen

    Thanks for the review, and your proposal to link to the Views support issue makes sense, so I added it. I also aligned the line length with the 80 char recommendation.

    I noticed that you added issue number first in the MR title. If it's a good idea, should an issue be created in https://www.drupal.org/project/infrastructure/ to add that in the template, if it's possible? Or will the move to Gitlab soon make it irrelevant to spend energy on?

    • bbu23 committed 610dba0d on 2.0.x authored by ressa
      Issue #3405842: Emphasize that menu items should only be added via menus...
  • Status changed to Fixed 11 months ago
  • 🇷🇴Romania bbu23

    Thank you, looks good to me, merged. I appreciate the 80 chars adjustments, I do prefer that for sure.
    As for infra I've never used it. I think Gitlab integration with issues is great, so I wouldn't invest time in that.
    Thanks!

  • 🇩🇰Denmark ressa Copenhagen

    Perfect, thanks!

  • 🇷🇴Romania bbu23

    Here's an idea, ressa. I added a new documentation guide for this module, since you've been proposing multiple changes to the readme. I think it's time to have a guide as well. If you'd like to contribute or even maintain the documentation guide, let me know. I created this issue for planning: https://www.drupal.org/project/menu_migration/issues/3408322 🌱 In-depth Module Documentation Active

  • 🇩🇰Denmark ressa Copenhagen

    This is a great idea! Though I think if we just copied over the README, we would have to maintain it both places ... So maybe link to the README, and use the documentation pages for advanced topics, such as how to add features, and create custom solutions? Like for example Leaflet . What do you think?

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024