Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'origin/development' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
johanzandstra committed Jan 18, 2018
2 parents b26e284 + 5c2c368 commit 9d65a25
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/controllers/SitemapController.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,14 @@ public function actionIndex()
$urlset->setAttribute('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9');
$dom->appendChild($urlset);

$siteurl = isset(Craft::$app->config->general)
&& isset(Craft::$app->config->general->siteUrl)
? Craft::$app->config->general->siteUrl
: null;

foreach($this->_createEntrySectionQuery()->all() as $item) {

$loc = rtrim($item['baseurl'], '/ ') . '/' . ($item['uri'] === '__home__' ? '' : $item['uri']);
$baseurl = rtrim($siteurl ?: $item['baseurl'], '/') . '/';
$loc = $baseurl . ($item['uri'] === '__home__' ? '' : $item['uri']);

$url = $dom->createElement('url');
$urlset->appendChild($url);
Expand All @@ -98,8 +102,8 @@ public function actionIndex()
}

foreach($this->_createEntryCategoryQuery()->all() as $item) {

$loc = rtrim($item['baseurl'], '/ ') . '/' . ($item['uri'] === '__home__' ? '' : $item['uri']);
$baseurl = rtrim($siteurl ?: $item['baseurl'], '/') . '/';
$loc = $baseurl . ($item['uri'] === '__home__' ? '' : $item['uri']);

$url = $dom->createElement('url');
$urlset->appendChild($url);
Expand Down Expand Up @@ -163,4 +167,4 @@ private function _createEntryCategoryQuery(): Query

}

?>
?>

0 comments on commit 9d65a25

Please sign in to comment.