xmlsitemap_node_frequency

Definition

xmlsitemap_node_frequency($node)
contributions/modules/xmlsitemap/xmlsitemap_node/xmlsitemap_node.module, line 95

Description

Calculate the change frequency of a node.

Parameters

$node: Data for a node retrieved by _xmlsitemap_node_links().

Return value

Number of seconds between updates

Related topics

Namesort iconDescription
XML SitemapNotify search engines of site updates.

Code

function xmlsitemap_node_frequency($node) {
  $age = time() - $node->changed;
  if (variable_get('xmlsitemap_node_count_comments', TRUE)) {
    $age = time() - max($node->changed, $node->last_comment_timestamp);
    $interval = 0;
    if (!empty($node->previously_changed) && isset($node->previous_comment)) {
      $interval = min($node->changed, $node->last_comment_timestamp) - max($node->previously_changed, $node->previous_comment);
    }
    elseif (!empty($node->previously_changed)) {
      $interval = min($node->changed, $node->last_comment_timestamp) - $node->previously_changed;
    }
    elseif (isset($node->previous_comment)) {
      $interval = min($node->changed, $node->last_comment_timestamp) - $node->previous_comment;
    }
  }
  else {
    $interval = empty($node->previously_changed) ? 0 : $node->changed - $node->previously_changed;
  }
  return max($age, $interval);
}