diff --git a/code/Controllers/SilverStripeNavigatorItem_LiveLink.php b/code/Controllers/SilverStripeNavigatorItem_LiveLink.php index e10ef67c..0dd68258 100644 --- a/code/Controllers/SilverStripeNavigatorItem_LiveLink.php +++ b/code/Controllers/SilverStripeNavigatorItem_LiveLink.php @@ -3,6 +3,7 @@ namespace SilverStripe\CMS\Controllers; use SilverStripe\CMS\Model\RedirectorPage; use SilverStripe\Control\Controller; +use SilverStripe\Core\Config\Config; use SilverStripe\Core\Convert; use SilverStripe\ORM\DataObject; use SilverStripe\Versioned\Versioned; @@ -56,13 +57,20 @@ class SilverStripeNavigatorItem_LiveLink extends SilverStripeNavigatorItem $record = $this->record; return ( $record->hasExtension(Versioned::class) + && $this->showLiveLink() && $record->hasStages() && $this->getLivePage() - // Don't follow redirects in preview, they break the CMS editing form - && !($this->record instanceof RedirectorPage) ); } + /** + * @return bool + */ + public function showLiveLink() + { + return (bool)Config::inst()->get(get_class($this->record), 'show_live_link'); + } + public function isActive() { return ( diff --git a/code/Controllers/SilverStripeNavigatorItem_StageLink.php b/code/Controllers/SilverStripeNavigatorItem_StageLink.php index 83aacefd..2c623c01 100644 --- a/code/Controllers/SilverStripeNavigatorItem_StageLink.php +++ b/code/Controllers/SilverStripeNavigatorItem_StageLink.php @@ -3,6 +3,7 @@ namespace SilverStripe\CMS\Controllers; use SilverStripe\CMS\Model\RedirectorPage; use SilverStripe\Control\Controller; +use SilverStripe\Core\Config\Config; use SilverStripe\Core\ClassInfo; use SilverStripe\Core\Convert; use SilverStripe\ORM\DataObject; @@ -62,13 +63,20 @@ class SilverStripeNavigatorItem_StageLink extends SilverStripeNavigatorItem $record = $this->record; return ( $record->hasExtension(Versioned::class) + && $this->showStageLink() && $record->hasStages() && $this->getDraftPage() - // Don't follow redirects in preview, they break the CMS editing form - && !($record instanceof RedirectorPage) ); } + /** + * @return bool + */ + public function showStageLink() + { + return (bool)Config::inst()->get(get_class($this->record), 'show_stage_link'); + } + public function isActive() { return ( diff --git a/code/Model/RedirectorPage.php b/code/Model/RedirectorPage.php index d87b3a87..8cc537c9 100644 --- a/code/Model/RedirectorPage.php +++ b/code/Model/RedirectorPage.php @@ -24,6 +24,10 @@ class RedirectorPage extends Page private static $icon_class = 'font-icon-p-redirect'; + private static $show_stage_link = false; + + private static $show_live_link = false; + private static $db = array( "RedirectionType" => "Enum('Internal,External','Internal')", "ExternalURL" => "Varchar(2083)" // 2083 is the maximum length of a URL in Internet Explorer. diff --git a/code/Model/SiteTree.php b/code/Model/SiteTree.php index db77b8bc..c3c8d911 100755 --- a/code/Model/SiteTree.php +++ b/code/Model/SiteTree.php @@ -137,6 +137,18 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi */ protected static $_allowedChildren = array(); + /** + * Determines if the Draft Preview panel will appear when in the CMS admin + * @var bool + */ + private static $show_stage_link = true; + + /** + * Determines if the Live Preview panel will appear when in the CMS admin + * @var bool + */ + private static $show_live_link = true; + /** * The default child class for this page. * Note: Value might be cached, see {@link $allowed_chilren}.