Negotiator amends: Make it possible to disable Preview links in the CMS

Existing functionality is limited to `RedirectorPage`

Another option would be to use the HiddenClass methodology
This commit is contained in:
Lee Bradley 2019-10-29 17:43:17 +00:00
parent c1159c849f
commit 31f99445bd
4 changed files with 30 additions and 4 deletions

View File

@ -58,11 +58,20 @@ class SilverStripeNavigatorItem_LiveLink extends SilverStripeNavigatorItem
$record->hasExtension(Versioned::class)
&& $record->hasStages()
&& $this->getLivePage()
// Don't follow redirects in preview, they break the CMS editing form
&& !($this->record instanceof RedirectorPage)
&& $this->showLiveLink()
);
}
public function showLiveLink()
{
try {
return $this->record->config()->get('show_live_link');
} catch (\BadMethodCallException $e) {
// Not using `config()` or similar
return false;
}
}
public function isActive()
{
return (

View File

@ -64,11 +64,20 @@ class SilverStripeNavigatorItem_StageLink extends SilverStripeNavigatorItem
$record->hasExtension(Versioned::class)
&& $record->hasStages()
&& $this->getDraftPage()
// Don't follow redirects in preview, they break the CMS editing form
&& !($record instanceof RedirectorPage)
&& $this->showStageLink()
);
}
public function showStageLink()
{
try {
return $this->record->config()->get('show_stage_link');
} catch (\BadMethodCallException $e) {
// Not using `config()` or similar
return false;
}
}
public function isActive()
{
return (

View File

@ -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.

View File

@ -137,6 +137,10 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
*/
protected static $_allowedChildren = array();
private static $show_stage_link = true;
private static $show_live_link = true;
/**
* The default child class for this page.
* Note: Value might be cached, see {@link $allowed_chilren}.