Drupal Sitemap does not show URL aliases

The Sitemap module

The Drupal Sitemap module generates a sitemap page and gives visitors a site overview. All categories and terms (i.e. vocabulary) are expanded optionally with node counts and RSS feeds.

The taxonomy URL paths on the sitemap page are not in the URL paths’ alias format

In Drupal 6, I encountered a problem: The taxonomy URL paths on the sitemap page are not in the URL paths’ alias format (which are generated by the Pathauto module). For example, the taxonomy URLs are in the format /taxonomy/term/28, instead of being displayed with the assigned URL alias, such as /category/projects.

Some of the solutions I found on the web are:

  1. Uninstalling and reinstalling the Sitemap and Pathauto modules;
  2. “Bulk update” in the Pathauto module settings;
  3. Changing modules weights.

However, none of the solutions listed above, nor any other solutions, worked for me. In order to fix this problem, I had to fix the Drupal Sitemap module code:

Code fix

Go to your sitemap module directory, back up and edit:

cd sites/all/modules/site_map
cp site_map.module site_map.module.backup
vi site_map.module

At function _site_map_taxonomy_tree, inside the elseif ($term->count) block, replace this line:

$term_item .= l($term->name, ($cat_depth < 0) ? taxonomy_term_path($term) : "taxonomy/term/$term->tid/$cat_depth", array('attributes' => array('title' => $term->description)));

with the following four lines:

/* show URL alias at sitemap */
$temp_term_path = taxonomy_term_path($term);
$temp_path_alias = drupal_get_path_alias($temp_term_path);
$term_item .= l($term->name, $temp_path_alias, array('attributes' => array('title' => $term->description)));

This fixed the sitemap page to show the URL aliases (clean URL) in the taxonomy links (see http://www.quizmeup.com/sitemap).

If you have any comment or a suggestion, please share.

Leave a Reply

*