public function Simplesitemap::getSitemap in Simple XML sitemap 8.2
Same name and namespace in other branches
- 8.3 src/Simplesitemap.php \Drupal\simple_sitemap\Simplesitemap::getSitemap()
Returns the whole sitemap, a requested sitemap chunk, or the sitemap index file.
Parameters
int $chunk_id:
Return value
string|false If no sitemap id provided, either a sitemap index is returned, or the whole sitemap, if the amount of links does not exceed the max links setting. If a sitemap id is provided, a sitemap chunk is returned. False if sitemap is not retrievable from the database.
File
- src/
Simplesitemap.php, line 177
Class
- Simplesitemap
- Class Simplesitemap @package Drupal\simple_sitemap
Namespace
Drupal\simple_sitemapCode
public function getSitemap($chunk_id = NULL) {
$chunk_info = $this
->fetchSitemapChunkInfo();
if (NULL === $chunk_id || !isset($chunk_info[$chunk_id])) {
if (count($chunk_info) > 1) {
// Return sitemap index, if there are multiple sitemap chunks.
return $this
->getSitemapIndex($chunk_info);
}
else {
// Return sitemap if there is only one chunk.
return count($chunk_info) === 1 && isset($chunk_info[SitemapGenerator::FIRST_CHUNK_INDEX]) ? $this
->fetchSitemapChunk(SitemapGenerator::FIRST_CHUNK_INDEX)->sitemap_string : FALSE;
}
}
else {
// Return specific sitemap chunk.
return $this
->fetchSitemapChunk($chunk_id)->sitemap_string;
}
}