You are here

function xmlsitemap_node_priority in XML sitemap 5

Same name and namespace in other branches
  1. 5.2 xmlsitemap_node/xmlsitemap_node.module \xmlsitemap_node_priority()

Calculate the priority of a node.

Parameters

$node: A node object:

Return value

A number between 0 and 1, or -1

Related topics

3 calls to xmlsitemap_node_priority()
theme_xmlsitemap_node_view_news in xmlsitemap_node/xmlsitemap_node.module
Display the nodes of a view as a Google News site map.
theme_xmlsitemap_node_view_sitemap in xmlsitemap_node/xmlsitemap_node.module
Display the nodes of a view as an XML site map.
_xmlsitemap_node_links in xmlsitemap_node/xmlsitemap_node.module
Get node links.

File

xmlsitemap_node/xmlsitemap_node.module, line 131
Adds nodes to the site map.

Code

function xmlsitemap_node_priority($node) {
  static $promote_priority;
  static $comment_priority;
  static $maxcomments;
  $promote_priority = isset($promote_priority) ? $promote_priority : variable_get('xmlsitemap_node_promote_priority', 0.3);
  $comment_priority = isset($comment_priority) ? $comment_priority : variable_get('xmlsitemap_node_comment_priority', 0.5);
  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 += $promote_priority;
    }
    if (!empty($maxcomments)) {
      $priority += $node->comment_count / $maxcomments * $comment_priority;
    }
    $priority = round($priority, 1);
    $priority = min($priority, 0.9);
  }
  return $priority;
}