You are here

function hook_xmlsitemap_root_attributes_alter in XML sitemap 8

Same name and namespace in other branches
  1. 7.2 xmlsitemap.api.php \hook_xmlsitemap_root_attributes_alter()
  2. 2.x xmlsitemap.api.php \hook_xmlsitemap_root_attributes_alter()

Alter the attributes used for the root element of the XML sitemap.

For example add an xmlns:video attribute:


<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:video="https://www.google.com/schemas/sitemap-video/1.1">

Parameters

array $attributes: An associative array of attributes to use in the root element of an XML sitemap.

\Drupal\xmlsitemap\XmlSitemapInterface $sitemap: The sitemap that is currently being generated.

1 invocation of hook_xmlsitemap_root_attributes_alter()
XmlSitemapWriter::getRootAttributes in src/XmlSitemapWriter.php
Return an array of attributes for the root element of the XML.

File

./xmlsitemap.api.php, line 238
Hooks provided by the XML sitemap module.

Code

function hook_xmlsitemap_root_attributes_alter(array &$attributes, \Drupal\xmlsitemap\XmlSitemapInterface $sitemap) {
  $attributes['xmlns:video'] = 'https://www.google.com/schemas/sitemap-video/1.1';
}