You are here

function xmlsitemap_taxonomy_create_link in XML sitemap 7.2

Same name and namespace in other branches
  1. 6.2 xmlsitemap_taxonomy/xmlsitemap_taxonomy.module \xmlsitemap_taxonomy_create_link()

Create a sitemap link from a taxonomy term.

Parameters

object $term: A taxonomy term object.

Return value

array An array representing a sitemap link.

3 calls to xmlsitemap_taxonomy_create_link()
xmlsitemap_taxonomy_term_insert in xmlsitemap_taxonomy/xmlsitemap_taxonomy.module
Implements hook_taxonomy_term_insert().
xmlsitemap_taxonomy_term_update in xmlsitemap_taxonomy/xmlsitemap_taxonomy.module
Implements hook_taxonomy_term_update().
xmlsitemap_taxonomy_xmlsitemap_process_taxonomy_term_links in xmlsitemap_taxonomy/xmlsitemap_taxonomy.module
Process taxonomy term sitemap links.

File

xmlsitemap_taxonomy/xmlsitemap_taxonomy.module, line 157
Main file for XML sitemap taxonomy.

Code

function xmlsitemap_taxonomy_create_link(stdClass &$term) {
  if (!isset($term->xmlsitemap)) {
    $term->xmlsitemap = array();
    if ($term->tid && ($link = xmlsitemap_link_load('taxonomy_term', $term->tid))) {
      $term->xmlsitemap = $link;
    }
  }
  $settings = xmlsitemap_link_bundle_load('taxonomy_term', $term->vocabulary_machine_name);
  $uri = entity_uri('taxonomy_term', $term);
  $term->xmlsitemap += array(
    'id' => $term->tid,
    'type' => 'taxonomy_term',
    'subtype' => $term->vocabulary_machine_name,
    'status' => $settings['status'],
    'status_default' => $settings['status'],
    'status_override' => 0,
    'priority' => $settings['priority'],
    'priority_default' => $settings['priority'],
    'priority_override' => 0,
  );

  // The following values must always be checked because they are volatile.
  // @todo How can/should we check taxonomy term access?
  $term->xmlsitemap['loc'] = $uri['path'];
  $term->xmlsitemap['access'] = 1;
  $term->xmlsitemap['language'] = isset($term->language) ? $term->language : LANGUAGE_NONE;
  return $term->xmlsitemap;
}