5 * Hooks provided by the Simple XML sitemap module.
14 * Alter the generated link data before the sitemap is saved.
15 * This hook gets invoked for every sitemap chunk generated.
17 * @param array &$links
18 * Array containing multilingual links generated for each path to be indexed.
20 function hook_simple_sitemap_links_alter(array &$links) {
22 // Remove German URL for a certain path in the hreflang sitemap.
23 foreach ($links as $key => $link) {
24 if ($link['path'] === 'node/1') {
26 // Remove 'loc' URL if it points to a german site.
27 if ($link['langcode'] === 'de') {
31 // If this 'loc' URL points to a non-german site, make sure to remove
32 // its german alternate URL.
34 if ($link['alternate_urls']['de']) {
35 unset($links[$key]['alternate_urls']['de']);
43 * Add arbitrary links to the sitemap.
45 * @param array &$arbitrary_links
47 function hook_simple_sitemap_arbitrary_links_alter(array &$arbitrary_links) {
49 // Add an arbitrary link.
50 $arbitrary_links[] = [
51 'url' => 'http://this-is-your-life.net/tyler',
54 // An ISO8601 formatted date.
55 'lastmod' => '2012-10-12T17:40:30+02:00',
57 'changefreq' => 'weekly',
59 ['path' => 'http://path-to-image.png']
62 // Add alternate URLs for every language of a multilingual site.
63 // Not necessary for monolingual sites.
65 'en' => 'http://this-is-your-life.net/de/tyler',
66 'de' => 'http://this-is-your-life.net/en/tyler',
72 * Alters the sitemap attributes shortly before XML document generation.
73 * Attributes can be added, changed and removed.
75 * @param array &$attributes
77 function hook_simple_sitemap_attributes_alter(array &$attributes) {
79 // Remove the xhtml attribute e.g. if no xhtml sitemap elements are present.
80 unset($attributes['xmlns:xhtml']);
84 * Alters attributes of the sitemap index shortly before XML document generation.
85 * Attributes can be added, changed and removed.
87 * @param array &$index_attributes
89 function hook_simple_sitemap_index_attributes_alter(array &$index_attributes) {
91 // Add some attribute to the sitemap index.
92 $index_attributes['name'] = 'value';
96 * Alter properties of and remove generator plugins.
98 * @param array $generators
100 function hook_simple_sitemap_url_generators_alter(array &$generators) {
102 // Remove the entity generator.
103 // Useful when creating your own entity generator plugin.
104 unset($generators['entity']);
106 // Change the weight of the arbitrary link generator.
107 $generators['arbitrary']['weight'] = -100;
111 * @} End of "addtogroup hooks".