diff --git a/code/Controllers/SilverStripeNavigatorItem_ArchiveLink.php b/code/Controllers/SilverStripeNavigatorItem_ArchiveLink.php index 00dab137..52627557 100644 --- a/code/Controllers/SilverStripeNavigatorItem_ArchiveLink.php +++ b/code/Controllers/SilverStripeNavigatorItem_ArchiveLink.php @@ -46,10 +46,8 @@ class SilverStripeNavigatorItem_ArchiveLink extends SilverStripeNavigatorItem public function getLink() { - return Controller::join_links( - $this->record->PreviewLink(), - '?archiveDate=' . urlencode($this->record->LastEdited ?? '') - ); + $link = $this->record->PreviewLink(); + return $link ? Controller::join_links($link, '?archiveDate=' . urlencode($this->record->LastEdited ?? '')) : ''; } public function canView($member = null) @@ -62,6 +60,7 @@ class SilverStripeNavigatorItem_ArchiveLink extends SilverStripeNavigatorItem && $this->isArchived() // Don't follow redirects in preview, they break the CMS editing form && !($record instanceof RedirectorPage) + && $this->getLink() ); } diff --git a/code/Controllers/SilverStripeNavigatorItem_LiveLink.php b/code/Controllers/SilverStripeNavigatorItem_LiveLink.php index 0dd68258..32d72029 100644 --- a/code/Controllers/SilverStripeNavigatorItem_LiveLink.php +++ b/code/Controllers/SilverStripeNavigatorItem_LiveLink.php @@ -48,7 +48,8 @@ class SilverStripeNavigatorItem_LiveLink extends SilverStripeNavigatorItem public function getLink() { - return Controller::join_links($this->getLivePage()->PreviewLink(), '?stage=Live'); + $link = $this->getLivePage()->PreviewLink(); + return $link ? Controller::join_links($link, '?stage=Live') : ''; } public function canView($member = null) @@ -60,6 +61,7 @@ class SilverStripeNavigatorItem_LiveLink extends SilverStripeNavigatorItem && $this->showLiveLink() && $record->hasStages() && $this->getLivePage() + && $this->getLink() ); } diff --git a/code/Controllers/SilverStripeNavigatorItem_StageLink.php b/code/Controllers/SilverStripeNavigatorItem_StageLink.php index 2c623c01..280f8cd9 100644 --- a/code/Controllers/SilverStripeNavigatorItem_StageLink.php +++ b/code/Controllers/SilverStripeNavigatorItem_StageLink.php @@ -50,8 +50,12 @@ class SilverStripeNavigatorItem_StageLink extends SilverStripeNavigatorItem public function getLink() { $date = Versioned::current_archived_date(); + $link = $this->record->PreviewLink(); + if (!$link) { + return ''; + } return Controller::join_links( - $this->record->PreviewLink(), + $link, '?stage=Stage', $date ? '?archiveDate=' . $date : null ); @@ -66,6 +70,7 @@ class SilverStripeNavigatorItem_StageLink extends SilverStripeNavigatorItem && $this->showStageLink() && $record->hasStages() && $this->getDraftPage() + && $this->getLink() ); } diff --git a/code/Controllers/SilverStripeNavigatorItem_Unversioned.php b/code/Controllers/SilverStripeNavigatorItem_Unversioned.php index ac489827..bc532efc 100644 --- a/code/Controllers/SilverStripeNavigatorItem_Unversioned.php +++ b/code/Controllers/SilverStripeNavigatorItem_Unversioned.php @@ -19,7 +19,7 @@ class SilverStripeNavigatorItem_Unversioned extends SilverStripeNavigatorItem public function getLink() { - return $this->getRecord()->PreviewLink(); + return $this->getRecord()->PreviewLink() ?? ''; } public function getTitle() @@ -42,6 +42,7 @@ class SilverStripeNavigatorItem_Unversioned extends SilverStripeNavigatorItem return ( !$this->getRecord()->hasExtension(Versioned::class) && $this->showUnversionedLink() + && $this->getLink() ); }