diff --git a/code/controller/CMSMain.php b/code/controller/CMSMain.php index ed2801de..5de891fc 100755 --- a/code/controller/CMSMain.php +++ b/code/controller/CMSMain.php @@ -497,6 +497,19 @@ JS; return $form; } + + public function currentPageID() { + $id = parent::currentPageID(); + + // Fall back to homepage record + if(!$id) { + $homepageSegment = RootURLController::get_homepage_link(); + $homepageRecord = DataObject::get_one('SiteTree', sprintf('"URLSegment" = \'%s\'', $homepageSegment)); + if($homepageRecord) $id = $homepageRecord->ID; + } + + return $id; + } //------------------------------------------------------------------------------------------// // Data saving handlers