function xmlsitemap_node_create_link in XML sitemap 7.2
Same name and namespace in other branches
- 6.2 xmlsitemap_node/xmlsitemap_node.module \xmlsitemap_node_create_link()
Create a sitemap link from a node.
The link will be saved as $node->xmlsitemap.
Parameters
object $node: A node object.
4 calls to xmlsitemap_node_create_link()
- xmlsitemap_menu_create_link in xmlsitemap_menu/
xmlsitemap_menu.module - Create a sitemap link from a menu item.
- xmlsitemap_node_cron in xmlsitemap_node/
xmlsitemap_node.module - Implements hook_cron().
- xmlsitemap_node_node_update in xmlsitemap_node/
xmlsitemap_node.module - Implements hook_node_update().
- xmlsitemap_node_xmlsitemap_process_node_links in xmlsitemap_node/
xmlsitemap_node.module - Process node sitemap links.
File
- xmlsitemap_node/
xmlsitemap_node.module, line 219 - Default file for XML sitemap node.
Code
function xmlsitemap_node_create_link(stdClass $node) {
if (!isset($node->xmlsitemap) || !is_array($node->xmlsitemap)) {
$node->xmlsitemap = array();
if ($node->nid && ($link = xmlsitemap_link_load('node', $node->nid))) {
$node->xmlsitemap = $link;
}
}
$settings = xmlsitemap_link_bundle_load('node', $node->type);
$uri = entity_uri('node', $node);
$node->xmlsitemap += array(
'type' => 'node',
'id' => $node->nid,
'subtype' => $node->type,
'status' => $settings['status'],
'status_default' => $settings['status'],
'status_override' => 0,
'priority' => $settings['priority'],
'priority_default' => $settings['priority'],
'priority_override' => 0,
);
// Always recalculate changefreq and changecount.
$timestamps = xmlsitemap_node_get_timestamps($node);
$node->xmlsitemap['changefreq'] = $node->nid ? xmlsitemap_calculate_changefreq($timestamps) : 0;
$node->xmlsitemap['changecount'] = $node->nid ? count($timestamps) - 1 : 0;
// The following values must always be checked because they are volatile.
$node->xmlsitemap['loc'] = $uri['path'];
$node->xmlsitemap['lastmod'] = count($timestamps) ? max($timestamps) : 0;
$node->xmlsitemap['access'] = $node->nid ? xmlsitemap_node_view_access($node, drupal_anonymous_user()) : 1;
$node->xmlsitemap['language'] = isset($node->language) ? $node->language : LANGUAGE_NONE;
return $node->xmlsitemap;
}