simple_sitemap.api.php 897 Bytes
Newer Older
1
<?php
gbyte.co's avatar
gbyte.co committed
2

3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
/**
 * @file
 * Hooks provided by the Simple XML sitemap module.
 */

/**
 * @addtogroup hooks
 * @{
 */

/**
 * Alter the generated link data before the sitemap is saved.
 * This hook gets invoked for every sitemap chunk generated.
 *
 * @param array &$links
gbyte.co's avatar
gbyte.co committed
18
 *   Array containing multilingual links generated for each path to be indexed.
19 20
 */
function hook_simple_sitemap_links_alter(&$links) {
21 22

  // Remove German URL for a certain path in the hreflang sitemap.
gbyte.co's avatar
gbyte.co committed
23
  foreach ($links as &$link) {
24 25 26 27 28 29 30 31 32 33 34
    if ($link['path'] == 'node/1') {
      // Remove 'loc' URL if it points to a german site.
      if ($link['langcode'] == 'de') {
        unset($link);
      }
      // If this 'loc' URL points to a non-german site, make sure to remove
      // its german alternate URL.
      else {
        unset($link['alternate_urls']['de']);
      }
    }
35 36 37 38 39 40
  }
}

/**
 * @} End of "addtogroup hooks".
 */