You are here

function xmlsitemap_node_get_priority in XML sitemap 6

Get the node priority in the sitemap.

Parameters

$node: The node object.

$load: TRUE if priority_override must be loaded from the module table.

Return value

The priority for the node.

See also

xmlsitemap_node_set_priority()

1 call to xmlsitemap_node_get_priority()
xmlsitemap_node_xmlsitemap_links in xmlsitemap_node/xmlsitemap_node.module
Implementation of hook_xmlsitemap_links().

File

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

Code

function xmlsitemap_node_get_priority($node, $load = FALSE) {
  if (!isset($node->priority_override) && $load) {
    $priority_override = db_result(db_query("SELECT xn.priority_override FROM {xmlsitemap_node} xn ON WHERE xn.nid = %d", $node->nid));
    if ($priority_override !== FALSE) {
      $node->priority_override = $priority_override;
    }
  }
  if (isset($node->priority_override) && $node->priority_override != -2.0) {
    $priority = $node->priority_override;
  }
  elseif (($priority = variable_get('xmlsitemap_node_type_priority_' . $node->type, 0.5)) != -1.0) {
    if ($node->promote) {
      $priority += variable_get('xmlsitemap_node_promote_priority', 0.3);
    }
    $priority += $node->comment_ratio * variable_get('xmlsitemap_node_comment_priority', 0.2);
  }
  if (!isset($priority)) {
    $priority = -1.0;
  }
  return $priority;
}