Compatibility with Domain Menus

Created on 6 May 2024, 11 months ago
Updated 7 August 2024, 8 months ago

Problem/Motivation

As a user of the Domain menus module, I want to display menus in the sitemap per domain. This is currently possible by enabling "Configuration by domain" on the sitemap setting page then, activating plugins and exporting configuration per each domain.

However this is a tedious task to do on a site with a lot of domains configured. I need a new sitemap plugin to display the domain menu automatically per domain.

Steps to reproduce

* Install Domain menus
* Create several domains - more than 5 is already a lot to deal with
* Enable the sitemap module
* Configure the sitemap module for each domain
* Result: you need to repeat the configure operation for each domain
* Expectation: A new plugin to do the configuration once and share it with all domains.

Proposed resolution

Implement a new sitemap plugin to display a domain menu depending on the current domain.

Remaining tasks

* Implement the plugin
* Write test
* Review code

Feature request
Status

Needs work

Version

2.0

Component

Code

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @matthieuscarset
  • Pipeline finished with Failed
    11 months ago
    Total: 228s
    #165415
  • Issue was unassigned.
  • Status changed to Needs review 11 months ago
  • Test failing because of an unrelated issue I think (e.g. SitemapBookTest).

    Unassigning this issue from me.

    Ready for review.

  • 🇨🇦Canada mparker17 UTC-4

    @matthieuscarset, thank you for the contribution!

    I think that the test (and some, but not all of the lints) is failing because the domain_menus module is not present in the test environment, so it cannot resolve the \Drupal\domain_menus\DomainMenusConstants import in the DomainMenuSitemapDeriver.

    There are two ways that we could proceed:

    1. We could modify sitemap.info.yml to include domain_menus as one of the test_dependencies as part of this patch.
      If we go this route, we will also need to write automated tests.
    2. We could create a new patch to the domain_menus module, and implement the Sitemap plugin there.
      This may sound like a lot of work, but I believe it would mostly consist of opening a new issue, creating a new issue fork, copying the plugin you wrote here and modifying the namespace lines, and updating domain_menus.info.yml
      This is possible because the Sitemap module uses Drupal's Plugin API , which allows plugins for one module (e.g.: Sitemap plugins) to exist inside another module (e.g.: domain menus). The Plugin code is only run if both modules are installed. I can't think of a module that defines a Sitemap plugin at the moment, but, for example, Drupal core's Field module allows plugins of type Field to be created, and the contrib Address module defines its own Field plugin to for a [post] address field.

    As a Sitemap module maintainer, I would prefer the second option (i.e.: patch domain_menus), because the Sitemap module maintainers' current policy is only to maintain Sitemap plugins for Drupal core (e.g.: front page (system module), book, menu, taxonomy, etc.), and let other module maintainers use the Plugin API to add Sitemap plugins in their own module. (this policy exists because the Sitemap module maintainers are all volunteers, and we don't have very much time to maintain this module if other modules change).

    That being said...

    1. If you would like some help writing a patch to the domain_menus module, I would be happy to be a mentor!
    2. If the domain_menus module maintainer — @drpldrp — is unwilling to accept a Sitemap plugin, and you are willing to become a Sitemap module maintainer, then I would be open to revisiting our policy to only maintain Sitemap plugins for Drupal core.

    @matthieuscarset, what do you think?

  • Thank you for your reply @mparker17

    I agree it would be better to have this plugin in Domain Menus. I originally proposed this plugin there indeed (see referenced issue) but it was "rejected".

    I could publish a new module specifically for this sitemap plugin but if you offer, i am happy to maintain the plugin here.

    Let me know what you prefer.

  • 🇨🇦Canada mparker17 UTC-4

    Hmm... let me think about it.

    In the meantime, I've pushed some code linting fixes, but tests are still failing, because I think composer.json is taking precedence over sitemap.info.yml.

    Once I get it working, would you be willing to write a test for the new functionality?

  • Status changed to Needs work 11 months ago
  • Yes of course. Thank you for your help.

    Let me know when/how I can help to take this plugin further.

  • 🇨🇦Canada mparker17 UTC-4

    mparker17 changed the visibility of the branch 3445396-compatibility-with-domain to hidden.

  • 🇨🇦Canada mparker17 UTC-4

    mparker17 changed the visibility of the branch 3445396-compatibility-with-domain to hidden.

  • 🇨🇦Canada mparker17 UTC-4

    A follow-up! Thank you for your patience with me!

    As part of 📌 Drupal 11 compatibility fixes for sitemap Fixed , I had to move the book-related functionality into a new <code>modules/sitemap_book/ submodule (although I couldn't figure out how to move the config schema, so I created Split sitemap_book config schema from sitemap schema Active to handle that).

    (I had to do this because the book module became a contrib module and was deleted from core )

    I think that gives us a pattern that we can reuse to add support for the Domain Menus for Domains module !

    I have hidden the (old) branch associated with this issue (i.e.: based on old sitemap module code).

    @matthieuscarset, may I trouble you to create a new branch for this issue (i.e.: based on newer sitemap module code), and put the code to support the domain_menus module into a modules/sitemap_domain_menus/, and add some tests? Once the changes are ready to merge, if you are still willing, then I will make you a maintainer of sitemap.

  • 🇨🇦Canada mparker17 UTC-4

    Adding "Needs tests" tag.

Production build 0.71.5 2024