function theme_xmlsitemap_node_view_news in XML sitemap 5
Same name and namespace in other branches
- 5.2 xmlsitemap_node/xmlsitemap_node.module \theme_xmlsitemap_node_view_news()
Display the nodes of a view as a Google News site map.
Related topics
File
- xmlsitemap_node/
xmlsitemap_node.module, line 494 - Adds nodes to the site map.
Code
function theme_xmlsitemap_node_view_news($view, $nodes, $type) {
drupal_set_header('Content-Type: text/xml; charset=utf-8');
$output .= '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
$output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"' . "\n";
$output .= ' xmlns:news="http://www.google.com/schemas/sitemap-news/0.9"' . "\n";
$output .= ' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' . "\n";
$output .= ' xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9' . "\n";
$output .= ' http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">' . "\n";
foreach ($nodes as $node) {
$lastmod = variable_get('xmlsitemap_node_count_comments', TRUE) ? max($node->changed, $node->last_comment_timestamp) : $node->changed;
$output .= ' <url>' . "\n";
$output .= ' <loc>' . xmlsitemap_url('node/' . $node->nid, $node->alias, NULL, NULL, TRUE) . '</loc>' . "\n";
$output .= ' <lastmod>' . gmdate('Y-m-d\\TH:i:s+00:00', $lastmod) . '</lastmod>' . "\n";
$output .= ' <changefreq>' . _xmlsitemap_frequency(xmlsitemap_node_frequency($node)) . '</changefreq>' . "\n";
$output .= ' <priority>' . number_format(xmlsitemap_node_priority($node), 1) . '</priority>' . "\n";
$output .= ' <news:news>' . "\n";
$output .= ' <news:publication_date>' . gmdate('Y-m-d\\TH:i:s+00:00', $node->created) . '</news:publication_date>' . "\n";
$output .= ' </news:news>' . "\n";
$output .= ' </url>' . "\n";
}
$output .= '</urlset>';
print $output;
module_invoke_all('exit');
exit;
}