You are here

function hook_simple_sitemap_arbitrary_links_alter in Simple XML sitemap 8.3

Same name and namespace in other branches
  1. 8.2 simple_sitemap.api.php \hook_simple_sitemap_arbitrary_links_alter()
  2. 4.x simple_sitemap.api.php \hook_simple_sitemap_arbitrary_links_alter()

Add arbitrary links to the sitemap.

Parameters

array &$arbitrary_links:

string $sitemap_variant:

1 invocation of hook_simple_sitemap_arbitrary_links_alter()
ArbitraryUrlGenerator::getDataSets in src/Plugin/simple_sitemap/UrlGenerator/ArbitraryUrlGenerator.php
@inheritdoc

File

./simple_sitemap.api.php, line 48
Hooks provided by the Simple XML Sitemap module.

Code

function hook_simple_sitemap_arbitrary_links_alter(array &$arbitrary_links, $sitemap_variant) {

  // Add an arbitrary link to all sitemap variants.
  $arbitrary_links[] = [
    'url' => 'http://some-arbitrary-link/',
    'priority' => '0.5',
    // An ISO8601 formatted date.
    'lastmod' => '2012-10-12T17:40:30+02:00',
    'changefreq' => 'weekly',
    'images' => [
      [
        'path' => 'http://path-to-image.png',
      ],
    ],
    // Add alternate URLs for every language of a multilingual site.
    // Not necessary for monolingual sites.
    'alternate_urls' => [
      'en' => 'http://this-is-your-life.net/de/tyler',
      'de' => 'http://this-is-your-life.net/en/tyler',
    ],
  ];

  // Add an arbitrary link to the 'fight_club' sitemap variant only.
  switch ($sitemap_variant) {
    case 'fight_club':
      $arbitrary_links[] = [
        'url' => 'http://this-is-your-life.net/tyler',
      ];
      break;
  }
}