Skip to content
Browse files

BUG Use AbsoluteLiveLink() for CMS previews

It uses the correct live URLSegments for its parents
by setting the global Versioned reading mode correctly,
see 8a514d8 for detail.
  • Loading branch information...
1 parent 8a514d8 commit cec461b767c7ddeaa6da3047d4b65bab43f98f7d @chillu chillu committed
Showing with 8 additions and 9 deletions.
  1. +8 −9 code/controllers/CMSMain.php
View
17 code/controllers/CMSMain.php
@@ -573,22 +573,21 @@ public function getEditForm($id = null, $fields = null) {
$fields->push($idField = new HiddenField("ID", false, $id));
// Necessary for different subsites
- $fields->push($liveURLField = new HiddenField("AbsoluteLink", false, $record->AbsoluteLink()));
- $fields->push($liveURLField = new HiddenField("LiveLink"));
- $fields->push($stageURLField = new HiddenField("StageLink"));
+ $fields->push($liveLinkField = new HiddenField("AbsoluteLink", false, $record->AbsoluteLink()));
+ $fields->push($liveLinkField = new HiddenField("LiveLink"));
+ $fields->push($stageLinkField = new HiddenField("StageLink"));
$fields->push(new HiddenField("TreeTitle", false, $record->TreeTitle));
$fields->push(new HiddenField('Sort','', $record->Sort));
if($record->ID && is_numeric( $record->ID ) ) {
- $liveRecord = Versioned::get_one_by_stage('SiteTree', 'Live', "\"SiteTree\".\"ID\" = $record->ID");
- if($liveRecord) {
- $liveURLField->setValue(Controller::join_links($liveRecord->AbsoluteLink(), '?stage=Live'));
+ $liveLink = $record->getAbsoluteLiveLink();
+ if($liveLink) $liveLinkField->setValue($liveLink);
+ if(!$deletedFromStage) {
+ $stageLink = Controller::join_links($record->AbsoluteLink(), '?stage=Stage');
+ if($stageLink) $stageLinkField->setValue($stageLink);
}
}
- if(!$deletedFromStage) {
- $stageURLField->setValue(Controller::join_links($record->AbsoluteLink(), '?stage=Stage'));
- }
// Added in-line to the form, but plucked into different view by LeftAndMain.Preview.js upon load
if(in_array('CMSPreviewable', class_implements($record)) && !$fields->fieldByName('SilverStripeNavigator')) {

0 comments on commit cec461b

Please sign in to comment.
Something went wrong with that request. Please try again.