Problem/Motivation

I need a certain menu included in the sitemap not to show it's title. When changing the title of any menu included in the sitemap to blank, the default title still appears in the title field.

Steps to reproduce

  1. Go to /admin/config/search/sitemap and include any menu in the sitemap and save the configuration.
  2. Scroll down to the Plugin settings and click on the tab of the menu. Leave the title field blank.
    Set the title to blank
  3. Access the site map page and noticed that the title no longer shows.
  4. Go back to the sitemap settings page, under plugin settings, notice that the default menu name is in the title field (not the blank value).
    The default menu name is back

Proposed resolution

Review the file src/Plugin/Sitemap/Menu.php and check for the conditional of the returned value for the function
public function settingsForm(array $form, FormStateInterface $form_state)

Remaining tasks

Change the function above to return a blank value if no value is set.

Issue fork sitemap-3206374

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

barone created an issue. See original summary.

barone’s picture

StatusFileSize
new676 bytes

Here's the patch that fixes the menu label issue.

barone’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, 2: title-of-menu-not-saved-3206374-1.patch, failed testing. View results

barone’s picture

Assigned: barone » Unassigned
monojithalder’s picture

Assigned: Unassigned » monojithalder
Status: Needs work » Needs review
StatusFileSize
new980 bytes

Status: Needs review » Needs work

The last submitted patch, 6: 3206374.patch, failed testing. View results

gngn’s picture

Status: Needs work » Needs review
StatusFileSize
new979 bytes
new255 bytes

The patch in #6 renders an empty h2 title (if we set it empty in the config).
That is because of the ' ' (string with one blank) in Menu::view().
I see no reason for this (and I think empty h2 tags are invalid HTML).
So I propose to use '' instead of ' '.

Status: Needs review » Needs work

The last submitted patch, 8: sitemap-title-of-menu-not-saved-3206374-8-d8.patch, failed testing. View results

Dmitriy.trt made their first commit to this issue’s fork.

dmitriy.trt’s picture

Status: Needs work » Needs review

Created MR !8 with the following alternative approach:

  • Specify NULL as a default title value of the Vocabulary, Book and Menu plugins. It's not just the menu one affected by the bug.
  • Use dynamic default value only in case the actual value is unset. This keeps empty title for those plugins.
  • Specify default title for the front page plugin in the annotation, as it's a static one.

It's better to use changes of this MR together with MR !7 of #3231515: Save settings of enabled plugins only, because otherwise default titles only appear once on the module installation.

  • akalata committed 450d02a on 8.x-2.x authored by Dmitriy.trt
    Issue #3206374 by Dmitriy.trt, barone, gngn, monojithalder: Title of a...
akalata’s picture

Status: Needs review » Fixed

Thanks @barone for the detailed write-up, everyone else for keeping this thread going, and to @dmitriy.trt for keeping the default values when a plugin is enabled.

Status: Fixed » Closed (fixed)

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