mirror of
https://github.com/silverstripe/silverstripe-subsites
synced 2024-10-22 09:05:55 +00:00
ENHANCEMENT Added isMainSite() to SiteTree decorator for subsites so it can be checked if we're currently viewing the main site or a sub-site
This commit is contained in:
parent
10d1ac7c42
commit
65dfa20031
@ -39,6 +39,15 @@ class SiteTreeSubsites extends DataObjectDecorator {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if we're currently looking at the main site.
|
||||||
|
* @return boolean TRUE main site | FALSE sub-site
|
||||||
|
*/
|
||||||
|
function isMainSite() {
|
||||||
|
if($this->owner->SubsiteID == 0) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update any requests to limit the results to the current site
|
* Update any requests to limit the results to the current site
|
||||||
*/
|
*/
|
||||||
@ -212,6 +221,7 @@ class SiteTreeSubsites extends DataObjectDecorator {
|
|||||||
$url = Director::absoluteURL($this->owner->Link());
|
$url = Director::absoluteURL($this->owner->Link());
|
||||||
return preg_replace('/\/\/[^\/]+\//', '//' . $this->owner->Subsite()->domain() . '/', $url);
|
return preg_replace('/\/\/[^\/]+\//', '//' . $this->owner->Subsite()->domain() . '/', $url);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user