theme_xmlsitemap_node_view_sitemap

Definition

theme_xmlsitemap_node_view_sitemap($view, $nodes, $type)
contributions/modules/xmlsitemap/xmlsitemap_node/xmlsitemap_node.module, line 410

Description

Display the nodes of a view as an XML site map.

Related topics

Namesort iconDescription
XML SitemapNotify search engines of site updates.

Code

function theme_xmlsitemap_node_view_sitemap($view, $nodes, $type) {
  drupal_set_header('Content-Type: text/xml; charset=utf-8');
  print '<?xml version="1.0" encoding="UTF-8"?>'."\n";
  print '<?xml-stylesheet type="text/xsl" href="'. xmlsitemap_url(drupal_get_path('module', 'xmlsitemap') .'/gss/gss.xsl') .'" ?>'."\n";
  print '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/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 '  </url>'."\n";
  }
  print '</urlset>';
  drupal_page_footer();
  exit;
}