As it is right now, hook_xmlsitemap_context_url_options_alter
doesn't allow you to alter the default values set by the xmlsitemap module. These values are 'base_url' and 'absolute'.
I'm using the xmlsitemap_i18n which generates sitemaps by language. This works very well, but the only catch is that all sitemaps gets generated using the same domain name. This isn't good enough when your site is set up to use language specific domains, such as domain.com, domain.dk, domain.no, domain.se etc.
I need the URLs generated for a given language-specific sitemap to reflect the domain which represents the language in question. The way I do this now is that I've modified the above xmlsitemap_sitemap_uri slightly, so that my hook can set the base_url depending on the $sitemap language. My change is simply:
index 93e935f..f07bc4f 100644
@@ -512,11 +512,11 @@ function xmlsitemap_sitemap_get_context_hash(array &$context) {
function xmlsitemap_sitemap_uri(stdClass $sitemap) {
$uri['path'] = 'sitemap.xml';
$uri['options'] = module_invoke_all('xmlsitemap_context_url_options', $sitemap->context);
- drupal_alter('xmlsitemap_context_url_options', $uri['options'], $sitemap->context);
$uri['options'] += array(
'absolute' => TRUE,
'base_url' => variable_get('xmlsitemap_base_url', $GLOBALS['base_url']),
);
+ drupal_alter('xmlsitemap_context_url_options', $uri['options'], $sitemap->context);
return $uri;
}
Would this make sense to change?