You are here

function xmlsitemap_node_frequency in XML sitemap 5.2

Same name and namespace in other branches
  1. 5 xmlsitemap_node/xmlsitemap_node.module \xmlsitemap_node_frequency()

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

3 calls to xmlsitemap_node_frequency()
theme_xmlsitemap_node_view_news in xmlsitemap_node/xmlsitemap_node.module
Display the nodes of a view as a Google News sitemap.
theme_xmlsitemap_node_view_sitemap in xmlsitemap_node/xmlsitemap_node.module
Display the nodes of a view as an XML sitemap.
xmlsitemap_node_xmlsitemap_links in xmlsitemap_node/xmlsitemap_node.module
Implementation of hook_xmlsitemap_links().

File

xmlsitemap_node/xmlsitemap_node.module, line 407
Adds nodes to the sitemap.

Code

function xmlsitemap_node_frequency($node) {
  $age = REQUEST_TIME - $node->changed;
  if (variable_get('xmlsitemap_node_count_comments', TRUE) && module_exists('comment')) {
    $age = REQUEST_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);
}