The menu structure generated by the module at /sitemap cannot be modified at all. This makes it impossible for other modules to jump in.

For example, Special Menu Items adds two new tokens on top of ( and ). Adding a hook would enable this module or a glue module to avoid these entries to generate a non existent link.

Comments

juampynr’s picture

Attaching patch to be reviewed.

Here is an example of how Special Menu Items could make links to <nolink> to point to the sitemap page:

  /**
   * Implements hook_site_map_menu_tree_alter
   *
   * Removes wrong URLs for special_menu_item paths
   */
  function mymodule_site_map_menu_tree_alter($menu_display) {
    foreach ($menu_display as $id => $item) {
      if (isset($item['#href']) &&
        ($item['#href'] == '<nolink>' || $item['#href'] == '<separator>')) {
          $menu_display[$id]['#href'] = 'sitemap/#';
      }
    }
    return $menu_display;
  }
juampynr’s picture

Attaching an improved patch with right paths in the diff.

juampynr’s picture

Sorry, uploaded the same one. Here it is.

darrell_ulm’s picture

Priority: Major » Normal

Looks interesting.

Hey offhand, can anyone tell me if there are possible security implications for this?

Just checking.

juampynr’s picture

Issue tags: +Needs security review

Here is the related issue on Special Menu Items: #1104940: filter out Special menu items from xml sitemap.

The risk of adding a hook would depend entirely on what the module that hooks in does, but it does not add any security breach by itself. However, I have added the tag Needs Sec Review to this issue.

webadpro’s picture

Has this been commited yet?

juampynr’s picture

No.

arpieb’s picture

Missed this issue in my search - a more complete and Drupal-standard way to invoke the alter implemented in the patch in #1588988: Add alter hook for menu tree prior to rendering.

darrell_ulm’s picture

Status: Needs review » Closed (duplicate)