Skip to content

Commit

Permalink
FIX InternalLink now allows picking hidden pages
Browse files Browse the repository at this point in the history
  • Loading branch information
Zauberfisch committed Jun 24, 2021
1 parent 28f3569 commit 560d26f
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/Link/InternalLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ public function getCMSFields(): FieldList {
$mapPages = function ($pages, &$arr, $prefix = '') use (&$mapPages) {
foreach ($pages as $page) {
$arr[$page->ID] = ($prefix ? "$prefix> " : "") . $page->MenuTitle;
if ($page->Children()->exists()) {
$mapPages($page->Children(), $arr, "$prefix=");
if ($page->AllChildren()->exists()) {
$mapPages($page->AllChildren(), $arr, "$prefix=");
}
}
return $arr;
Expand All @@ -44,7 +44,11 @@ public function getCMSFields(): FieldList {
* @return \SilverStripe\ORM\DataObject|null|SiteTree
*/
public function getPage(): ?SiteTree {
return $this->getPageID() ? SiteTree::get()->byID($this->getPageID()) : null;
$page = $this->getPageID() ? SiteTree::get()->byID($this->getPageID()) : null;
if ($page && $page->canView()) {
return $page;
}
return null;
}

/**
Expand Down

0 comments on commit 560d26f

Please sign in to comment.