function _xmlsitemap_output_index in XML sitemap 5.2
Same name and namespace in other branches
- 5 xmlsitemap.module \_xmlsitemap_output_index()
Generate the sitemap index.
Return value
A string containing the sitemap index
1 call to _xmlsitemap_output_index()
- xmlsitemap_output in xmlsitemap/
xmlsitemap.module - Menu callback; display the sitemap.
File
- xmlsitemap/
xmlsitemap.module, line 591 - Creates a sitemap compatible with the sitemaps.org schema.
Code
function _xmlsitemap_output_index() {
print '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
print '<sitemapindex 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/siteindex.xsd">' . "\n";
$chunk_size = variable_get('xmlsitemap_chunk_size', 50000);
$link_count = xmlsitemap_link_count();
for ($chunk = 0; $chunk < $link_count / $chunk_size; ++$chunk) {
print ' <sitemap>' . "\n";
print ' <loc>' . xmlsitemap_url("sitemap{$chunk}.xml", NULL, NULL, NULL, TRUE) . '</loc>' . "\n";
if ($chunk < $link_count / $chunk_size) {
$from = $chunk * $chunk_size;
if (!empty($chunk_size)) {
$lastmod = db_result(db_query_range("SELECT lastmod FROM {xmlsitemap} ORDER BY priority DESC, lastmod DESC, loc", $from, $chunk_size));
if (isset($lastmod) && $lastmod !== FALSE) {
print ' <lastmod>' . gmdate('Y-m-d\\TH:i:s+00:00', $lastmod) . '</lastmod>' . "\n";
}
}
}
print ' </sitemap>' . "\n";
}
print '</sitemapindex>';
}