Skip to content

Commit 30b2d62

Browse files
committed
exclude Multisites Sites from disallowed pages
1 parent 9fb261d commit 30b2d62

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

src/Controllers/RobotsController.php

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use SilverStripe\Control\Director;
88
use SilverStripe\Core\Manifest\ModuleLoader;
99
use SilverStripe\SiteConfig\SiteConfig;
10+
use Symbiote\Multisites\Model\Site;
1011
use Symbiote\Multisites\Multisites;
1112
use Wilr\GoogleSitemaps\GoogleSitemap;
1213

@@ -136,17 +137,30 @@ public function getDisallowedPages()
136137
}
137138

138139
if ($isGoogleSitemapsEnabled) {
139-
$googleSitemap = GoogleSitemap::singleton();
140+
$pages = SiteTree::get();
141+
142+
$isMultisitesEnabled = ModuleLoader::inst()
143+
->getManifest()
144+
->moduleExists('symbiote/silverstripe-multisites');
145+
if ($isMultisitesEnabled) {
146+
$pages = $pages->exclude([
147+
'ClassName' => Site::class
148+
]);
149+
}
150+
151+
$googleSitemap = GoogleSitemap::singleton();
140152
$isFiltered = (bool) $googleSitemap->config()->get('use_show_in_search');
141153
$filterFieldName = 'ShowInSearch';
142154
if (method_exists(GoogleSitemap::class, 'getFilterFieldName')) {
143155
$filterFieldName = $googleSitemap->getFilterFieldName();
144156
}
145157
if ($isFiltered) {
146-
return SiteTree::get()->exclude($filterFieldName, true);
158+
$pages = $pages->exclude($filterFieldName, true);
147159
} else {
148-
return SiteTree::get()->filter(['Priority' => '-1']);
160+
$pages = $pages->filter(['Priority' => '-1']);
149161
}
162+
163+
return $pages;
150164
}
151165

152166
return null;

0 commit comments

Comments
 (0)