From 7df47fd4cce7233bc25105a9b8857f9149c58141 Mon Sep 17 00:00:00 2001 From: trendschau Date: Sat, 27 Apr 2024 22:31:39 +0200 Subject: [PATCH] V.2.4.3 fix navigation after sorting or deleting base elements --- .../ControllerApiAuthorArticle.php | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/system/typemill/Controllers/ControllerApiAuthorArticle.php b/system/typemill/Controllers/ControllerApiAuthorArticle.php index 08f404d..6676d4d 100644 --- a/system/typemill/Controllers/ControllerApiAuthorArticle.php +++ b/system/typemill/Controllers/ControllerApiAuthorArticle.php @@ -893,13 +893,16 @@ class ControllerApiAuthorArticle extends Controller # get the content of the target folder $folderContent = $newFolder->folderContent; } - + # if the item has been moved within the same folder if($params['parent_id_from'] == $params['parent_id_to']) { - # we do not have to generate the full navigation, only this part - $clearFullNavi = false; - $naviFileName = $navigation->getNaviFileNameForPath($item->path); + if($params['parent_id_to'] != '') + { + # we do not have to generate the full navigation, only this part + $clearFullNavi = false; + $naviFileName = $navigation->getNaviFileNameForPath($item->path); + } # get key of item $itemKey = end($itemKeyPath); @@ -1046,8 +1049,16 @@ class ControllerApiAuthorArticle extends Controller return $response->withHeader('Content-Type', 'application/json')->withStatus(500); } - $naviFileName = $navigation->getNaviFileNameForPath($item->path); - $navigation->clearNavigation([$naviFileName, $naviFileName . '-extended']); + if(count($item->keyPathArray) == 1) + { + # if item on base level is deleted, clear the whole navigation + $navigation->clearNavigation(); + } + else + { + $naviFileName = $navigation->getNaviFileNameForPath($item->path); + $navigation->clearNavigation([$naviFileName, $naviFileName . '-extended']); + } $draftNavigation = $navigation->getFullDraftNavigation($urlinfo, $this->settings['langattr']);