Problem/Motivation

Menu links in Drupal can have a description, which is normally used as the tooltip shown when hovering
over the link. The Sitemap module lists menu links on the sitemap page, but it only shows the link title
and ignores that description.

Those descriptions are useful context for visitors browsing the sitemap, and increasingly for tools
that read a site's structure. Right now there is no way to surface that information on the sitemap.

Proposed resolution

Add an option in the Sitemap settings to display menu link descriptions on the sitemap page. When
enabled, each menu link is followed by its description, giving visitors and tools more context about
where the link leads.

The option is disabled by default, so the sitemap looks exactly the same as before unless a site
administrator chooses to turn it on.

Before

  • Products
    • Laptops
    • Accessories
    • Support Plans

After (with the option enabled)

  • Products: Browse our full catalog of devices and add-ons.
    • Laptops: Lightweight and high-performance models for work and play.
    • Accessories: Chargers, cases, and everything to complete your setup.
    • Support Plans: Extended warranty and priority technical assistance.

Issue fork sitemap-3606989

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

albeorte created an issue. See original summary.

albeorte’s picture

Issue summary: View changes

albeorte’s picture

A merge request has been created with the changes related to the issue. -> https://git.drupalcode.org/project/sitemap/-/merge_requests/62

Below is a demo showing what the sitemap would look like with the link descriptions, with the checkbox checked and unchecked:

  • Unchecked:

Sitemap without descriptions

  • Checked:

Show descriptions checkbox

Sitemap with descriptions

albeorte’s picture

Status: Active » Needs review

The changes are ready for review.

mparker17’s picture

I think this would be a helpful addition to the sitemap module!

Thank you, @albeorte, I will review soon!

mparker17’s picture

Status: Needs review » Needs work

@albeorte, thank you again for your contribution!

I've tested this and it works, but I would like to request a change to how it's done before I merge it.

I think it would be better to make the "Show menu link descriptions" checkbox into a Menu-plugin setting (i.e.: I don't think it should be a global setting that applies to all menu plugins on the Sitemap). Put another way, I'd like to be able to control whether to "Show menu link descriptions" separately for each Menu that I'm displaying on the Sitemap.

Changing this will involve moving the code from the global Settings form (i.e.: at \Drupal\sitemap\Form\SitemapSettingsForm) to the Menu plugin (i.e.: at \Drupal\sitemap\Plugin\Sitemap\Menu). Likewise, you will need to change where the setting is defined in the configuration schema, i.e.: from sitemap.settings to sitemap_plugin_settings.menu. You'll have to modify the upgrade hook to loop through each Menu plugin and set a default value for it; how you access the setting will change, and the test will change as well. Please let me know if you'd like some help: I think this would be a helpful addition to the module and - while I don't have a lot of time these days - I'd be happy to help get it over the finish line.


Because I've requested changes, I am going to move this back to Needs work.