Skip to content

Commit

Permalink
Merge pull request #21 from PlasticStudio/feature/noindex
Browse files Browse the repository at this point in the history
Write sitemap.xml to public/ if it exists
  • Loading branch information
monkeyfeet authored Jan 26, 2021
2 parents c945fc8 + 07b4e3e commit 9127145
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 9127145

Please sign in to comment.