mirror of
https://github.com/wilr/silverstripe-googlesitemaps.git
synced 2024-10-22 11:05:48 +02:00
Remove redirector pages (Fixes #43)
This commit is contained in:
parent
9f461b8d7c
commit
356350ede5
@ -56,6 +56,13 @@ class GoogleSitemap extends Object
|
||||
*/
|
||||
private static $routes = array();
|
||||
|
||||
/**
|
||||
* @config
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private static $exclude_redirector_pages = true;
|
||||
|
||||
/**
|
||||
* Decorates the given DataObject with {@link GoogleSitemapDecorator}
|
||||
* and pushes the class name to the registered DataObjects.
|
||||
@ -204,6 +211,7 @@ class GoogleSitemap extends Object
|
||||
$output = new ArrayList();
|
||||
$count = Config::inst()->get('GoogleSitemap', 'objects_per_sitemap');
|
||||
$filter = Config::inst()->get('GoogleSitemap', 'use_show_in_search');
|
||||
$redirector = Config::inst()->get('GoogleSitemap', 'exclude_redirector_pages');
|
||||
|
||||
// todo migrate to extension hook or DI point for other modules to
|
||||
// modify state filters
|
||||
@ -212,8 +220,15 @@ class GoogleSitemap extends Object
|
||||
}
|
||||
|
||||
if ($class == "SiteTree") {
|
||||
$filter = ($filter) ? "\"ShowInSearch\" = 1" : "";
|
||||
$instances = Versioned::get_by_stage('SiteTree', 'Live', $filter);
|
||||
$instances = Versioned::get_by_stage('SiteTree', 'Live');
|
||||
|
||||
if($filter) {
|
||||
$instances = $instances->filter('ShowInSearch', 1);
|
||||
}
|
||||
|
||||
if($redirector) {
|
||||
$instances = $instances->exclude('ClassName', 'RedirectorPage');
|
||||
}
|
||||
} elseif ($class == "GoogleSitemapRoute") {
|
||||
$instances = array_slice(self::$routes, ($page - 1) * $count, $count);
|
||||
$output = new ArrayList();
|
||||
|
Loading…
Reference in New Issue
Block a user