From 1bd7dce68a0e29288c768db6d40af2047b3fef0b Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Wed, 5 Sep 2007 06:42:26 +0000 Subject: [PATCH] Refactored CMS page-URL accessing to use ->AbsoluteLink(), which can be overridden by defining alternateAbsoluteLink() git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@41283 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- code/CMSMain.php | 10 ++++++++-- javascript/LeftAndMain_right.js | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/code/CMSMain.php b/code/CMSMain.php index ee7127f0..6c515ddc 100644 --- a/code/CMSMain.php +++ b/code/CMSMain.php @@ -282,8 +282,14 @@ JS; $idField->setValue($id); - if($record->ID && is_numeric( $record->ID ) ) $liveURLField->setValue(DB::query("SELECT URLSegment FROM SiteTree_Live WHERE ID = $id")->value()); - if(!$record->DeletedFromStage) $stageURLField->setValue($record->URLSegment); + if($record->ID && is_numeric( $record->ID ) ) { + $liveRecord = Versioned::get_one_by_stage('SiteTree', 'Live', "`SiteTree`.ID = $record->ID"); + if($liveRecord) $liveURLField->setValue($liveRecord->AbsoluteLink()); + } + + if(!$record->DeletedFromStage) { + $stageURLField->setValue($record->AbsoluteLink()); + } // getAllCMSActions can be used to completely redefine the action list if($record->hasMethod('getAllCMSActions')) { diff --git a/javascript/LeftAndMain_right.js b/javascript/LeftAndMain_right.js index a6b14061..58a4dbd1 100755 --- a/javascript/LeftAndMain_right.js +++ b/javascript/LeftAndMain_right.js @@ -433,7 +433,7 @@ StageLink.prototype = { var linkVal = linkField ? linkField.value : null; if(linkVal) { if(this.id != 'viewArchivedSite') this.style.display = ''; - this.href = this.baseURL() + linkVal + '/' + this.getVars; + this.href = linkVal + this.getVars; } else { if(this.id != 'viewArchivedSite') this.style.display = 'none'; }