You are here

function hook_query_xmlsitemap_generate_alter in XML sitemap 2.x

Same name and namespace in other branches
  1. 8 xmlsitemap.api.php \hook_query_xmlsitemap_generate_alter()
  2. 6.2 xmlsitemap.api.php \hook_query_xmlsitemap_generate_alter()
  3. 7.2 xmlsitemap.api.php \hook_query_xmlsitemap_generate_alter()

Alter the query selecting data from {xmlsitemap} during sitemap generation.

Parameters

QueryAlterableInterface $query: A Query object describing the composite parts of a SQL query.

See also

hook_query_TAG_alter()

1 function implements hook_query_xmlsitemap_generate_alter()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

language_query_xmlsitemap_generate_alter in ./xmlsitemap.module
Implements hook_query_TAG_alter() for language module.

File

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

Code

function hook_query_xmlsitemap_generate_alter(QueryAlterableInterface $query) {
  $sitemap = $query
    ->getMetaData('sitemap');
  if (!empty($sitemap->context['vocabulary'])) {
    $node_condition = $query
      ->andConditionGroup();
    $node_condition
      ->condition('type', 'taxonomy_term');
    $node_condition
      ->condition('subtype', $sitemap->context['vocabulary']);
    $normal_condition = $query
      ->andConditionGroup();
    $normal_condition
      ->condition('type', 'taxonomy_term', '<>');
    $condition = $query
      ->orConditionGroup();
    $condition
      ->condition($node_condition);
    $condition
      ->condition($normal_condition);
    $query
      ->condition($condition);
  }
}