Things like image, mobile, and video sitemaps will need to be able to alter at least the XML header as well as actual link output. Currently its not possible because the use case hasn't come up with domains or languages.

Comments

dave reid’s picture

#764658: Use XMLWriter class instead of fwrite() is now probably something I want to look into more closely since it would *really* help this feature out.

dave reid’s picture

Priority: Normal » Major
dave reid’s picture

So now I have this smart idea that SitemapTypes should just have to extend the XMLSitemapWriter class and that it should be pretty much automatic and we only have to handle which class is loaded to generate the XML:

For example, to generate a news sitemap:

class XMLSitemapNewsWriter extends XMLSitemapWriter {
  public function getRootAttributes() {
    $attributes = parent::getRootAttributes();
    $attributes['xmlns:news'] = 'http://www.google.com/schemas/sitemap-news/0.9';
    return $attributes;
  }

  public function writeSitemapElement($name, array &$element) {
    $element['news:news'] = array(
      'news:publication' => array(
        'news:name' => variable_get('site_name', 'Drupal'),
        'news:language' => $GLOBALS['language']->language,
      ),
      'news:title' => 'My Node Title',
    );

    return parent::writeSitemapElement($name, $element);
  }
}
dave reid’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.