Commit 0498fe94 authored by gbyte.co's avatar gbyte.co

Showing empty page if erroreously no sitemap exists in the db instead of php error.

parent cf7db613
......@@ -19,7 +19,8 @@ class SimplesitemapController {
* Returns the whole sitemap, a requested sitemap chunk, or the sitemap index file.
*
* @param int $sitemap_id
* Id of the sitemap chunk.
* Optional ID of the sitemap chunk. If none provided, the first chunk or
* the sitemap index is fetched.
*
* @return object Response
* Returns an XML response.
......@@ -27,6 +28,7 @@ class SimplesitemapController {
public function get_sitemap($sitemap_id = NULL) {
$sitemap = new Simplesitemap;
$output = $sitemap->get_sitemap($sitemap_id);
$output = !$output ? '' : $output;
// Display sitemap with correct xml header.
// return new CacheableResponse($output, Response::HTTP_OK, array('content-type' => 'application/xml'));
......
......@@ -153,10 +153,12 @@ class Simplesitemap {
// Return sitemap if there is only one chunk.
else {
return $this->sitemap[1]->sitemap_string;
if (isset($this->sitemap[1])) {
return $this->sitemap[1]->sitemap_string;
}
return FALSE;
}
}
// Return specific sitemap chunk.
else {
return $this->sitemap[$sitemap_id]->sitemap_string;
......@@ -177,7 +179,6 @@ class Simplesitemap {
/**
* Saves the sitemap to the db.
*/
// private function save_sitemap() {
public static function save_sitemap($values) {
db_insert('simple_sitemap')
->fields(array(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment