xmlsitemap_node_priority

Definition

xmlsitemap_node_priority($node)
contributions/modules/xmlsitemap/xmlsitemap_node/xmlsitemap_node.module, line 134

Description

Calculate the priority of a node.

Parameters

$node: A node object

Return value

A number between 0 and 1, or -1

Related topics

Namesort iconDescription
XML SitemapNotify search engines of site updates.

Code

function xmlsitemap_node_priority($node) {
  static $maxcomments;
  if (!isset($maxcomments)) {
    $maxcomments = 0;
    if (module_exists('comment')) {
      $maxcomments = db_result(db_query("SELECT MAX(comment_count) FROM {node_comment_statistics}"));
    }
  }
  $priority = $node->priority_override;
  if (!isset($node->priority_override)) {
    $priority = 0;
    $priority += variable_get("xmlsitemap_node_type_priority_$node->type", 0.5);
    if ($node->promote) {
      $priority += variable_get('xmlsitemap_node_promote_priority', 0.3);
    }
    if (!empty($maxcomments)) {
      $priority += $node->comment_count / $maxcomments * variable_get('xmlsitemap_node_comment_priority', 0.5);
    }
    $priority = round($priority, 1);
    $priority = min($priority, 1);
  }
  return $priority;
}