Merge pull request #2120 from open-sausages/pulls/4.0/fix-in-section

BUG Fix InSection failing on non-page controllers
This commit is contained in:
Chris Joe 2018-03-12 13:17:55 +13:00 committed by GitHub
commit a02410b983
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -759,8 +759,8 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
public function InSection($sectionName)
{
$page = Director::get_current_page();
while ($page && $page->exists()) {
if ($sectionName == $page->URLSegment) {
while ($page instanceof SiteTree && $page->exists()) {
if ($sectionName === $page->URLSegment) {
return true;
}
$page = $page->Parent();