MINOR Fall back to homepage record for CMSMain->PreviewLink()

This commit is contained in:
Ingo Schommer 2011-07-06 08:38:23 +02:00
parent 38db63c3b0
commit 17131f7a2a
1 changed files with 13 additions and 0 deletions

View File

@ -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