public function validURLSegment() { $isValid = parent::validURLSegment(); // Veto the validation rules if its false. In this case, some logic // needs to be duplicated from parent to find out the exact reason the validation failed. if (!$isValid) { $IDFilter = $this->ID ? "AND \"SiteTree\".\"ID\" <> {$this->ID}" : null; $parentFilter = null; if (Config::inst()->get('SiteTree', 'nested_urls')) { if ($this->ParentID) { $parentFilter = " AND \"SiteTree\".\"ParentID\" = {$this->ParentID}"; } else { $parentFilter = ' AND "SiteTree"."ParentID" = 0'; } } $origDisableSubsiteFilter = Subsite::$disable_subsite_filter; Subsite::$disable_subsite_filter = true; $existingPage = DataObject::get_one('SiteTree', "\"URLSegment\" = '{$this->URLSegment}' {$IDFilter} {$parentFilter}", false); Subsite::$disable_subsite_filter = $origDisableSubsiteFilter; $existingPageInSubsite = DataObject::get_one('SiteTree', "\"URLSegment\" = '{$this->URLSegment}' {$IDFilter} {$parentFilter}", false); // If URL has been vetoed because of an existing page, // be more specific and allow same URLSegments in different subsites $isValid = !($existingPage && $existingPageInSubsite); } return $isValid; }