Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

NEW SiteTree->PreviewLink() for fine grained URL control

  • Loading branch information...
commit 76aeec70e70f05c4ba46bd02f85c32b4ee64af29 1 parent f9504ee
@chillu chillu authored
View
8 code/controllers/SilverStripeNavigator.php
@@ -246,7 +246,7 @@ public function getMessage() {
}
public function getLink() {
- return Controller::join_links($this->record->AbsoluteLink(), '?stage=Stage');
+ return Controller::join_links($this->record->PreviewLink(), '?stage=Stage');
}
public function canView($member = null) {
@@ -299,7 +299,7 @@ public function getMessage() {
}
public function getLink() {
- return Controller::join_links($this->record->AbsoluteLink(), '?stage=Live');
+ return Controller::join_links($this->record->PreviewLink(), '?stage=Live');
}
public function canView($member = null) {
@@ -333,7 +333,7 @@ class SilverStripeNavigatorItem_ArchiveLink extends SilverStripeNavigatorItem {
static $priority = 40;
public function getHTML() {
- $this->recordLink = $this->record->AbsoluteLink();
+ $this->recordLink = $this->record->PreviewLink();
return "<a class=\"ss-ui-button\" href=\"$this->recordLink?archiveDate={$this->record->LastEdited}\" target=\"_blank\">". _t('ContentController.ARCHIVEDSITE', 'Preview version') ."</a>";
}
@@ -350,7 +350,7 @@ public function getMessage() {
}
public function getLink() {
- return $this->record->AbsoluteLink() . '?archiveDate=' . $this->record->LastEdited;
+ return $this->record->PreviewLink() . '?archiveDate=' . $this->record->LastEdited;
}
public function canView($member = null) {
View
12 code/model/SiteTree.php
@@ -412,6 +412,18 @@ public function AbsoluteLink($action = null) {
return Director::absoluteURL($this->Link($action));
}
}
+
+ /**
+ * Base link used for previewing. Defaults to absolute URL,
+ * in order to account for domain changes, e.g. on multi site setups.
+ * Does not contain hints about the stage, see {@link SilverStripeNavigator} for details.
+ *
+ * @param string $action See {@link Link()}
+ * @return string
+ */
+ public function PreviewLink($action = null) {
+ return $this->AbsoluteLink($action);
+ }
/**
* Return the link for this {@link SiteTree} object relative to the SilverStripe root.
Please sign in to comment.
Something went wrong with that request. Please try again.