Skip to content
This repository has been archived by the owner on Jan 9, 2021. It is now read-only.

Commit

Permalink
Updated sitemap controller
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmomathieu committed Aug 10, 2016
1 parent 722d2e0 commit bb3f748
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions application/modules/sitemap/controllers/sitemap.php
Expand Up @@ -33,7 +33,7 @@
* @category Common Functions
* @author Cosmo Mathieu <cosmo@cosmointeractive.co>
* @link http://pagestudiocms.com/docs/
* @version 1.0
* @version 1.1
* @since Version 1.2.0
* @uses https://github.com/chemicaloliver/codeigniter-sitemaps
*/
Expand Down Expand Up @@ -61,7 +61,10 @@ public function xml()
{
$this->load->library('sitemaps');
$this->load->model('sitemap_model');


// Override default required fields
$this->sitemaps->set_item_keys(['loc', 'lastmod']);

// First get a list of published entries and their urls
$posts = $this->sitemap_model->get_entries();

Expand All @@ -70,17 +73,24 @@ public function xml()
$item = array(
"loc" => site_url($post->slug),
"lastmod" => date("c", strtotime($post->modified_date)),
"changefreq" => "hourly",
"priority" => "0.8"
// **CHANGED** 20160810 - Not sure these are helping at all...
// "changefreq" => "monthly",
// "priority" => "0.8"
);

$this->sitemaps->add_item($item);
}

// Save the file to the root dir of the site
// File name may change when compression is enabled
$file_name = $this->sitemaps->build("sitemap.xml", false);

$reponses = $this->sitemaps->ping(site_url($file_name));
// $file_name = $this->sitemaps->build("sitemap.xml", false);
$file_name = $this->sitemaps->build(null, false);

// Notify search engines of our changes
$reponses = $this->sitemaps->ping(site_url($file_name));

header ("Content-Type:text/xml");
print($file_name);
exit;
}
}

0 comments on commit bb3f748

Please sign in to comment.