theme_xmlsitemap_node_view_news($view, $nodes, $type)
contributions/modules/xmlsitemap/xmlsitemap_node/xmlsitemap_node.module, line 435
Display the nodes of a view as a Google News site map.
| Name | Description |
|---|---|
| XML Sitemap | Notify search engines of site updates. |
function theme_xmlsitemap_node_view_news($view, $nodes, $type) {
drupal_set_header('Content-Type: text/xml; charset=utf-8');
print '<?xml version="1.0" encoding="UTF-8"?>'."\n";
print '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"'."\n";
print ' xmlns:news="http://www.google.com/schemas/sitemap-news/0.9"'."\n";
print ' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'."\n";
print ' xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9'."\n";
print ' 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;
print ' <url>'."\n";
print ' <loc>'. xmlsitemap_url('node/'. $node->nid, $node->alias, NULL, NULL, TRUE) .'</loc>'."\n";
print ' <lastmod>'. gmdate('Y-m-d\TH:i:s+00:00', $lastmod) .'</lastmod>'."\n";
print ' <changefreq>'. xmlsitemap_frequency(xmlsitemap_node_frequency($node)) .'</changefreq>'."\n";
print ' <priority>'. number_format(xmlsitemap_node_priority($node), 1) .'</priority>'."\n";
print ' <news:news>'."\n";
print ' <news:publication_date>'. gmdate('Y-m-d\TH:i:s+00:00', $node->created) .'</news:publication_date>'."\n";
print ' </news:news>'."\n";
print ' </url>'."\n";
}
print '</urlset>';
drupal_page_footer();
exit;
}