Merge pull request #126 from danaenz/subsites-support

Add Subsite support
This commit is contained in:
Will Rossiter 2018-03-06 11:48:33 +13:00 committed by GitHub
commit c00f420a8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -18,6 +18,15 @@ class GoogleSitemapExtension extends DataExtension
if ($this->owner->hasMethod('AbsoluteLink')) { if ($this->owner->hasMethod('AbsoluteLink')) {
$hostHttp = parse_url(Director::protocolAndHost(), PHP_URL_HOST); $hostHttp = parse_url(Director::protocolAndHost(), PHP_URL_HOST);
// Subsite support
if (class_exists('Subsite')) {
// Subsite will have a different domain from Director::protocolAndHost
if ($subsite = Subsite::currentSubsite()) {
$hostHttp = parse_url(Director::protocol() . $subsite->getPrimaryDomain(), PHP_URL_HOST);
}
}
$objHttp = parse_url($this->owner->AbsoluteLink(), PHP_URL_HOST); $objHttp = parse_url($this->owner->AbsoluteLink(), PHP_URL_HOST);
if ($objHttp != $hostHttp) { if ($objHttp != $hostHttp) {