mirror of
https://github.com/silverstripe/silverstripe-subsites
synced 2024-10-22 11:05:55 +02:00
Merge branch '2.8' into 2
This commit is contained in:
commit
3ec16bbe56
@ -64,3 +64,12 @@ SilverStripe\Subsites\Admin\SubsiteAdmin:
|
|||||||
SilverStripe\SiteConfig\SiteConfigLeftAndMain:
|
SilverStripe\SiteConfig\SiteConfigLeftAndMain:
|
||||||
extensions:
|
extensions:
|
||||||
- SilverStripe\Subsites\Extensions\SubsiteMenuExtension
|
- SilverStripe\Subsites\Extensions\SubsiteMenuExtension
|
||||||
|
|
||||||
|
---
|
||||||
|
Name: subsite-preview-elemental
|
||||||
|
Only:
|
||||||
|
classexists: DNADesign\Elemental\Models\BaseElement
|
||||||
|
---
|
||||||
|
DNADesign\Elemental\Models\BaseElement:
|
||||||
|
extensions:
|
||||||
|
- SilverStripe\Subsites\Extensions\BaseElementSubsites
|
||||||
|
33
src/Extensions/BaseElementSubsites.php
Normal file
33
src/Extensions/BaseElementSubsites.php
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\Subsites\Extensions;
|
||||||
|
|
||||||
|
use SilverStripe\Control\HTTP;
|
||||||
|
use SilverStripe\ORM\DataExtension;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extension for the BaseElement object to add subsites support for CMS previews
|
||||||
|
*/
|
||||||
|
class BaseElementSubsites extends DataExtension
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Set SubsiteID to avoid errors when a page doesn't exist on the CMS domain.
|
||||||
|
*
|
||||||
|
* @param string &$link
|
||||||
|
* @param string|null $action
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function updatePreviewLink(&$link)
|
||||||
|
{
|
||||||
|
// Get subsite ID from the element or from its page. Defaults to 0 automatically.
|
||||||
|
$subsiteID = $this->owner->SubsiteID;
|
||||||
|
if (is_null($subsiteID)) {
|
||||||
|
$page = $this->owner->getPage();
|
||||||
|
if ($page) {
|
||||||
|
$subsiteID = $page->SubsiteID;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$link = HTTP::setGetVar('SubsiteID', intval($subsiteID), $link);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user