Taxonomy term page path alias not being used
| Project: | XML sitemap |
| Version: | 6.x-1.1 |
| Component: | xmlsitemap_taxonomy.module |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs work |
Jump to:
If a taxonomy term page has an alias generated by pathauto or the like (i.e. alias exists in `url_alias` table), this alias may not be included in the xml sitemap; instead, the original url (taxonomy/term/%tid) may be used.
I've changed the code to use drupal_get_path_alias() to check for a path alias before committing the path to the object that will eventually be written to the database (and eventually to the sitemap file). This is safe, since drupal_get_path_alias() returns "An aliased path if one was found, or the original path if no alias was found."
A patch is attached. First drupal patch, hope it is in the right format.
I am not sure if this should just be added, or if you want to have a UI option for the user to select this (since, there have not been a zillion complaints about this)
| Attachment | Size | Status | Test result | Operations |
|---|---|---|---|---|
| xmlsitemap_taxonomy_path-alias.patch | 604 bytes | Ignored | None | None |

#1
This is really unnessary. We run all the database paths through url() during generation in 6.x-1.x which automatically looks up url aliases.
<?phpfunction _xmlsitemap_create_cache_chunk($fp, $chunk_size, $chunk = 0) {
$links = db_query_range("SELECT xsm.loc, xsm.module, xsm.type, xsm.id, xsm.sid, xsm.changed, xsm.changefreq, xsm.priority". xmlsitemap_sitemap_query() ."ORDER BY xsm.priority DESC, xsm.changed DESC, xsm.changefreq, xsm.loc", $start, $chunk_size);
while ($link = db_fetch_object($links)) {
if ($link->type == 'frontpage') {
$url = url(NULL, array('absolute' => TRUE));
}
else {
$url = url($link->loc, array('absolute' => TRUE));
}
?>
So you need to debug this and figure out why url() isn't getting the url alias during generation.
#2
This was only a problem for taxonomy terms that existed before the xmlsitemap module was installed (I believe that Iforgot to mention this. Now I rememeber why I didn't submit it yesterday).
This patch, in my case, fixed the problem completely.
#3
I keep asking myself "Isn't this resolved by Global Redirect"? Note that Global Redirect module weight is set very high and xmlsitemap's modules' weights needs to be after Global Redirect.