Skip to content

Commit

Permalink
fixed sub item handling
Browse files Browse the repository at this point in the history
  • Loading branch information
koertho committed Feb 7, 2023
1 parent 0202ef8 commit b4016be
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/Menu/MenuBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,17 @@ public function getMenu(ItemInterface $root, int $pid, $level = 1, $host = null,

// Check whether there will be subpages
if ($page->subpages > 0) {
$this->getMenu($item, (int) $page->id, $level++, $host, $options);

$level++;
$childRecords = Database::getInstance()->getChildRecords($page->id, 'tl_page');
if (!$options['showLevel']
|| $options['showLevel'] >= $level
|| (!$options['hardLimit']
&& ((null !== $requestPage && $requestPage->id === $page->id) || \in_array($requestPage->id, $childRecords, true)))) {
$item->setDisplayChildren(false);

$item->setDisplayChildren(false);
if (!$options['showLevel'] || $options['showLevel'] >= $level || (
!$options['hardLimit'] && ($requestPage->id == $page->id || \in_array($requestPage->id, $childRecords)))) {
$item->setDisplayChildren(true);
}

$this->getMenu($item, (int) $page->id, $level, $host, $options);
}

switch ($page->type) {
Expand Down

0 comments on commit b4016be

Please sign in to comment.