Add Subsite support by ensuring the host matches correctly to the current Subsite domain and protocol

This commit is contained in:
Danae Miller-Clendon 2017-10-06 12:11:53 +13:00
parent 930fd7f9ac
commit 27898476d8
1 changed files with 9 additions and 0 deletions

View File

@ -18,6 +18,15 @@ class GoogleSitemapExtension extends DataExtension
if ($this->owner->hasMethod('AbsoluteLink')) {
$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);
if ($objHttp != $hostHttp) {