Skip to content

Commit

Permalink
Write sitemap.xml to public/ if it exists
Browse files Browse the repository at this point in the history
  • Loading branch information
monkeyfeet committed Jan 26, 2021
1 parent c562583 commit 07b4e3e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Pages/XMLSitemapController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace PlasticStudio\Sitemap\Pages;

use PageController;
use SilverStripe\Control\Director;

class XMLSitemap_Controller extends PageController {

Expand All @@ -22,7 +23,12 @@ public function UpdateXMLFile(){
$xml = $this->GetXMLValue();

// get link to xml file to be created/updated in site root
$file = BASE_PATH . '/sitemap.xml';
if (Director::publicDir()) {
$base_path = Director::publicFolder();
} else {
$base_path = Director::baseFolder();
}
$file = $base_path . '/sitemap.xml';
$fp = fopen($file, "w");
// prepend xml tag to result (gets excluded from curl)
/*$output = '<?xml version="1.0" encoding="UTF-8"?>';
Expand Down

0 comments on commit 07b4e3e

Please sign in to comment.