Added the Porter Stemmer module to improve searches. This doesn't deal with some...
[yaffs-website] / web / modules / contrib / simple_sitemap / simple_sitemap.api.php
1 <?php
2
3 /**
4  * @file
5  * Hooks provided by the Simple XML sitemap module.
6  */
7
8 /**
9  * @addtogroup hooks
10  * @{
11  */
12
13 /**
14  * Alter the generated link data before the sitemap is saved.
15  * This hook gets invoked for every sitemap chunk generated.
16  *
17  * @param array &$links
18  *   Array containing multilingual links generated for each path to be indexed.
19  */
20 function hook_simple_sitemap_links_alter(array &$links) {
21
22   // Remove German URL for a certain path in the hreflang sitemap.
23   foreach ($links as $key => $link) {
24     if ($link['path'] === 'node/1') {
25
26       // Remove 'loc' URL if it points to a german site.
27       if ($link['langcode'] === 'de') {
28         unset($links[$key]);
29       }
30
31       // If this 'loc' URL points to a non-german site, make sure to remove
32       // its german alternate URL.
33       else {
34         if ($link['alternate_urls']['de']) {
35           unset($links[$key]['alternate_urls']['de']);
36         }
37       }
38     }
39   }
40 }
41
42 /**
43  * Add arbitrary links to the sitemap.
44  *
45  * @param array &$arbitrary_links
46  */
47 function hook_simple_sitemap_arbitrary_links_alter(array &$arbitrary_links) {
48
49   // Add an arbitrary link.
50   $arbitrary_links[] = [
51     'url' => 'http://this-is-your-life.net/tyler',
52     'priority' => '0.5',
53
54     // An ISO8601 formatted date.
55     'lastmod' => '2012-10-12T17:40:30+02:00',
56
57     'changefreq' => 'weekly',
58     'images' => [
59       ['path' => 'http://path-to-image.png']
60     ],
61
62     // Add alternate URLs for every language of a multilingual site.
63     // Not necessary for monolingual sites.
64     'alternate_urls' => [
65       'en' => 'http://this-is-your-life.net/de/tyler',
66       'de' => 'http://this-is-your-life.net/en/tyler',
67     ]
68   ];
69 }
70
71 /**
72  * Alters the sitemap attributes shortly before XML document generation.
73  * Attributes can be added, changed and removed.
74  *
75  * @param array &$attributes
76  */
77 function hook_simple_sitemap_attributes_alter(array &$attributes) {
78
79   // Remove the xhtml attribute e.g. if no xhtml sitemap elements are present.
80   unset($attributes['xmlns:xhtml']);
81 }
82
83 /**
84  * Alters attributes of the sitemap index shortly before XML document generation.
85  * Attributes can be added, changed and removed.
86  *
87  * @param array &$index_attributes
88  */
89 function hook_simple_sitemap_index_attributes_alter(array &$index_attributes) {
90
91   // Add some attribute to the sitemap index.
92   $index_attributes['name'] = 'value';
93 }
94
95 /**
96  * Alter properties of and remove generator plugins.
97  *
98  * @param array $generators
99  */
100 function hook_simple_sitemap_url_generators_alter(array &$generators) {
101
102   // Remove the entity generator.
103   // Useful when creating your own entity generator plugin.
104   unset($generators['entity']);
105
106   // Change the weight of the arbitrary link generator.
107   $generators['arbitrary']['weight'] = -100;
108 }
109
110 /**
111  * @} End of "addtogroup hooks".
112  */