function xmlsitemap_node_views_query_alter in XML sitemap 5
Same name and namespace in other branches
- 5.2 xmlsitemap_node/xmlsitemap_node.module \xmlsitemap_node_views_query_alter()
Implementation of hook_views_query_alter().
Related topics
File
- xmlsitemap_node/
xmlsitemap_node.module, line 422 - Adds nodes to the site map.
Code
function xmlsitemap_node_views_query_alter(&$query, &$view, $summary, $level) {
switch ($view->page_type) {
case 'xmlsitemap_news':
$query
->add_field('created', 'node');
case 'xmlsitemap_sitemap':
$xn_join = array(
'left' => array(
'table' => 'node',
'field' => 'nid',
),
'right' => array(
'field' => 'nid',
),
);
$ua_join = array(
'left' => array(
'table' => 'xmlsitemap_node',
'field' => 'pid',
),
'right' => array(
'field' => 'pid',
),
);
$query
->add_table('xmlsitemap_node', FALSE, 1, $xn_join);
$query
->add_table('url_alias', FALSE, 1, $ua_join);
if (module_exists('comment')) {
$query
->add_table('node_comment_statistics');
$query
->add_field('comment_count', 'node_comment_statistics');
$query
->add_field('last_comment_timestamp', 'node_comment_statistics');
$query
->add_field('previous_comment', 'xmlsitemap_node');
}
$query
->add_field('type', 'node');
$query
->add_field('promote', 'node');
$query
->add_field('changed', 'node');
$query
->add_field('previously_changed', 'xmlsitemap_node');
$query
->add_field('priority_override', 'xmlsitemap_node');
$query
->add_field('dst', 'url_alias', 'alias');
break;
}
}