diff --git a/CHANGELOG.md b/CHANGELOG.md index a7cebdd..61ae1c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # sitemap Changelog +## 1.0.6 - 2018-01-18 +### Changed +- Use the siteUrl from the general config as prefered base URL +- Checked compatibility with Craft RC6 + ## 1.0.5 - 2017-12-18 ### Fixed - Fixed bug if there are no sections or categories in the website diff --git a/README.md b/README.md index 1d1fb02..1d82b53 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ The sitemap is compatible with the ![sitemaps.org](https://www.sitemaps.org/prot ## Requirements -This plugin requires Craft CMS 3.0.0-RC1 or later. +This plugin requires Craft CMS 3.0.0-RC6 or later. ## Installation @@ -35,7 +35,7 @@ To install the plugin, follow these instructions. ## XML-sitemap Roadmap - User (custom) url entry section -- Privide a way hide entries from the list +- Provide a way hide entries from the list - Add a Ping for search engines - Display the last 20 visits from search engines diff --git a/composer.json b/composer.json index b193cd6..b5bf737 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "dolphiq/sitemap", "description": "Craft 3 plugin that provides an easy way to provide and manage a XML sitemap for search engines like Google and Bing", "type": "craft-plugin", - "version": "1.0.5", + "version": "1.0.6", "keywords": [ "craft", "cms", @@ -22,7 +22,7 @@ } ], "require": { - "craftcms/cms": "^3.0.0-RC1", + "craftcms/cms": "^3.0.0-RC6", "jaybizzle/crawler-detect": "1.*" }, "repositories": [ diff --git a/src/controllers/SitemapController.php b/src/controllers/SitemapController.php index 7f14726..8bd7032 100644 --- a/src/controllers/SitemapController.php +++ b/src/controllers/SitemapController.php @@ -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); @@ -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); @@ -163,4 +167,4 @@ private function _createEntryCategoryQuery(): Query } -?> \ No newline at end of file +?>