function xmlsitemap_node_create_link in XML sitemap 6.2
Same name and namespace in other branches
- 7.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
$node: A node object.
4 calls to xmlsitemap_node_create_link()
- xmlsitemap_node_comment in xmlsitemap_node/
xmlsitemap_node.module - Implements hook_comment().
- xmlsitemap_node_nodeapi in xmlsitemap_node/
xmlsitemap_node.module - Implements hook_nodeapi().
- xmlsitemap_node_update_6198 in xmlsitemap_node/
xmlsitemap_node.install - Migrate 6.x-1.x node data.
- xmlsitemap_node_xmlsitemap_process_node_links in xmlsitemap_node/
xmlsitemap_node.module - Process node sitemap links.
File
- xmlsitemap_node/
xmlsitemap_node.module, line 201
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 = xmlsitemap_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 : '';
return $node->xmlsitemap;
}