function _xmlsitemap_output_index in XML sitemap 5
Same name and namespace in other branches
- 5.2 xmlsitemap/xmlsitemap.module \_xmlsitemap_output_index()
Generate the site map index.
Parameters
$link_count:: An integer containing the total number of links in the site
Return value
A string containing the site map index
Related topics
1 call to _xmlsitemap_output_index()
- _xmlsitemap_update_cache in ./
xmlsitemap.module - Update the cached site map files.
File
- ./
xmlsitemap.module, line 437 - Creates a site map compatible with the sitemaps.org schema.
Code
function _xmlsitemap_output_index($link_count) {
$output = '';
$xsl_path = file_directory_path() . '/xmlsitemap/gss.xsl';
$xsl_path = file_exists($xsl_path) ? _xmlsitemap_file_create_url($xsl_path) : base_path() . drupal_get_path('module', 'xmlsitemap') . '/gss/gss.xsl';
$output .= '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
$output .= '<?xml-stylesheet type="text/xsl" href="' . $xsl_path . '" ?>' . "\n";
$output .= '<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/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/siteindex.xsd">' . "\n";
$chunk_size = variable_get('xmlsitemap_chunk_size', 50000);
for ($chunk = 0; $chunk < $link_count / $chunk_size; ++$chunk) {
$output .= '<sitemap><loc>' . xmlsitemap_url("sitemap{$chunk}.xml", NULL, NULL, NULL, TRUE) . '</loc>';
$previous = $chunk * $chunk_size;
$links = array_slice(_xmlsitemap_links(), $previous, $chunk_size);
$output .= '<lastmod>' . gmdate('Y-m-d\\TH:i:s+00:00', array_reduce($links, '_xmlsitemap_chunk_last_change')) . '</lastmod>';
$output .= "</sitemap>\n";
}
$output .= '</sitemapindex>';
return $output;
}