mirror of
https://github.com/silverstripe/silverstripe-subsites
synced 2024-10-22 11:05:55 +02:00
Merge pull request #374 from creative-commoners/pulls/2.0/cms-preview-nonbreakage
FIX apply SubsiteID getVar to CMS Preview fetches
This commit is contained in:
commit
19f0162265
@ -28,5 +28,5 @@ This method is called when a pages are being copied between the main site or ano
|
|||||||
### alternateAbsoluteLink
|
### alternateAbsoluteLink
|
||||||
This method modifies the absolute link to contain the valid subsite domain
|
This method modifies the absolute link to contain the valid subsite domain
|
||||||
|
|
||||||
### alternatePreviewLink
|
### updatePreviewLink
|
||||||
This method modifies the preview link for the CMS.
|
This method modifies the preview link for the CMS.
|
||||||
|
@ -101,7 +101,7 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Update links and forms with GET/POST SubsiteID param, so we remaing on the current subsite.
|
* Update links and forms with GET/POST SubsiteID param, so we remaing on the current subsite.
|
||||||
* The initial link for the iframe comes from SiteTreeSubsites::alternatePreviewLink.
|
* The initial link for the iframe comes from SiteTreeSubsites::updatePreviewLink.
|
||||||
*
|
*
|
||||||
* This is done so we can use the CMS domain for displaying previews so we prevent single-origin
|
* This is done so we can use the CMS domain for displaying previews so we prevent single-origin
|
||||||
* violations and SSL cert problems that come up when iframing content from a different URL.
|
* violations and SSL cert problems that come up when iframing content from a different URL.
|
||||||
|
@ -382,17 +382,31 @@ class SiteTreeSubsites extends DataExtension
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Use the CMS domain for iframed CMS previews to prevent single-origin violations
|
* Use the CMS domain for iframed CMS previews to prevent single-origin violations
|
||||||
* and SSL cert problems.
|
* and SSL cert problems. Always set SubsiteID to avoid errors because a page doesn't
|
||||||
* @param null $action
|
* exist on the CMS domain.
|
||||||
|
*
|
||||||
|
* @param string &$link
|
||||||
|
* @param string|null $action
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function updatePreviewLink(&$link, $action = null)
|
||||||
|
{
|
||||||
|
$url = Director::absoluteURL($this->owner->Link($action));
|
||||||
|
$link = HTTP::setGetVar('SubsiteID', $this->owner->SubsiteID, $url);
|
||||||
|
return $link;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function is marked as deprecated for removal in 5.0.0 in silverstripe/cms
|
||||||
|
* so now simply passes execution to where the functionality exists for backwards compatiblity.
|
||||||
|
*
|
||||||
|
* @param string|null $action
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function alternatePreviewLink($action = null)
|
public function alternatePreviewLink($action = null)
|
||||||
{
|
{
|
||||||
$url = Director::absoluteURL($this->owner->Link());
|
$link = '';
|
||||||
if ($this->owner->SubsiteID) {
|
return $this->updatePreviewLink($link, $action);
|
||||||
$url = HTTP::setGetVar('SubsiteID', $this->owner->SubsiteID, $url);
|
|
||||||
}
|
|
||||||
return $url;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user