Skip to content

Commit

Permalink
Look for a menu when none specified
Browse files Browse the repository at this point in the history
  • Loading branch information
billtomczak committed Jul 15, 2022
1 parent 4d0f775 commit e4f5e50
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions src/site/router.php
Original file line number Diff line number Diff line change
Expand Up @@ -355,13 +355,31 @@ public function preprocess($query)
$parts = $query;

if ($view) {
if ($view == 'downloads') {
$listMenu = $this->helper->getMenuItemForListOfFiles($id)
?: $this->helper->getMenuItemForListOfFiles(0);
switch ($view) {
case 'item':
if (empty($itemId)) {
// Try to find a menu
$menu = $this->helper->getMenuItemForFile($id);
if (empty($menu)) {
if ($category = $this->helper->getCategoryFromFileId($id)) {
$menu = $this->helper->getMenuItemForCategoryTreeRecursively($category->id);
}
}
if ($menu) {
$itemId = $menu->id;
}
}
break;

case 'downloads':
$listMenu = $this->helper->getMenuItemForListOfFiles($id)
?: $this->helper->getMenuItemForListOfFiles(0);

if ($listMenu) {
$itemId = $listMenu->id;
}
break;

if ($listMenu) {
$itemId = $listMenu->id;
}
}

} elseif ($task && $id) {
Expand Down

0 comments on commit e4f5e50

Please sign in to comment.