This patch is intended to help those that want to enchance xmlsitemap in similar ways as the above image. This solution is closely tied to a large custom project, and not meant to be direclty applied to the module.
While working on a drupal project that had a rather nifty multi-region implementation (todo: future blog), it was required to have a single sitemap for all regions with default and alternate urls in it, as suggested by google - https://support.google.com/webmasters/answer/189077
None of the modules that extend xmlsitemap fit the bill -
- domain_xmlsitemap module - https://www.drupal.org/project/domain_xmlsitemap
- xmlsitemap_i18n module - comes within the xmlsitemap download
- this issue trying to address the same thing - #1670086: using rel="alternate" rather than multiple sitemaps by language context
After exploring all options, the custom changes submitted in this issue were made. Hope this helps others. (NOTE: code has been simplified to work for anybody, and show what's going on)
Comment | File | Size | Author |
---|---|---|---|
#1 | using_rel_alternate-2514288-1.patch | 4.76 KB | Sumeet.Pareek |
xmlsitemap_alternate_url_enhancement.png | 277.86 KB | Sumeet.Pareek |
Comments
Comment #1
Sumeet.Pareek CreditAttribution: Sumeet.Pareek as a volunteer commentedAfter exploring all options, the custom changes submitted in this issue were made. Hope this helps others. (NOTE: code has been simplified to work for anybody, and show what's going on)
When there's time, I would try to work on getting this to work with entity_translation and other popular use cases.
Comment #2
Sumeet.Pareek CreditAttribution: Sumeet.Pareek as a volunteer commentedMoving to NR, since this issue was a "feature request" for custom enhancements, and feedback on the approach is welcome.
Comment #3
Sumeet.Pareek CreditAttribution: Sumeet.Pareek as a volunteer commentedComment #4
Dave ReidThis is totally already possible with the existing APIs - use hook_xmlsitemap_element_alter() and provide your data in $element in a way that format_xml_elements() understands. Marking as a duplicate of #2387557: Support more advanced XML element output