diff --git a/code/SiteTreeSubsites.php b/code/SiteTreeSubsites.php index e91cbc7..14f13fa 100644 --- a/code/SiteTreeSubsites.php +++ b/code/SiteTreeSubsites.php @@ -8,7 +8,7 @@ class SiteTreeSubsites extends DataObjectDecorator { '((Company Name))' => 'Title' ); - protected static $template_fields = array( + static $template_fields = array( "URLSegment", "Title", "MenuTitle", @@ -44,6 +44,8 @@ class SiteTreeSubsites extends DataObjectDecorator { * Update any requests to limit the results to the current site */ function augmentSQL(SQLQuery &$query) { + if(Subsite::$disable_subsite_filter) return; + // If you're querying by ID, ignore the sub-site - this is a bit ugly... if(strpos($query->where[0], ".`ID` = ") === false && strpos($query->where[0], ".ID = ") === false) { diff --git a/code/Subsite.php b/code/Subsite.php index a866c8d..2f7ae19 100644 --- a/code/Subsite.php +++ b/code/Subsite.php @@ -3,6 +3,8 @@ * A dynamically created subdomain. SiteTree objects can now belong to a subdomain */ class Subsite extends DataObject implements PermissionProvider { + + static $disable_subsite_filter = false; static $default_sort = 'Title'; @@ -323,6 +325,13 @@ SQL; 'SUBSITE_EDIT' => 'Edit Sub-site Details', ); } + + static function get_from_all_subsites($className, $filter = "", $sort = "", $join = "", $limit = "") { + self::$disable_subsite_filter = true; + $result = DataObject::get($className, $filter, $sort, $join, $limit); + self::$disable_subsite_filter = false; + return $result; + } } /**