Compatibility with Domain Menus

Created on 6 May 2024, about 2 months ago
Updated 7 May 2024, about 2 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.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @matthieuscarset
  • Pipeline finished with Failed
    about 2 months ago
    Total: 228s
    #165415
  • Issue was unassigned.
  • Status changed to Needs review about 2 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 about 2 months ago
  • Yes of course. Thank you for your help.

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

Production build 0.69.0 2024