diff --git a/Classes/Components/ExtraInfo.php b/Classes/Components/ExtraInfo.php index 03ad384..c84a13c 100644 --- a/Classes/Components/ExtraInfo.php +++ b/Classes/Components/ExtraInfo.php @@ -27,7 +27,10 @@ public function render() { $pathString = $this->parameters['pathString']; - if ($pathString == '/1/') { + $rootLocationId = $this->controller->getConfigResolver()->getParameter( 'content.tree_root.location_id' ); + + + if ( strpos( $pathString , '/' . $rootLocationId . '/' ) === false ) { return new Response(); } diff --git a/Classes/Components/SideMenu.php b/Classes/Components/SideMenu.php index c97ec39..b5c4ac2 100644 --- a/Classes/Components/SideMenu.php +++ b/Classes/Components/SideMenu.php @@ -29,11 +29,13 @@ public function render() $response->setPublic(); $response->setSharedMaxAge(86400); + $rootLocationId = $this->controller->getConfigResolver()->getParameter( 'content.tree_root.location_id' ); - + $subPath = explode( '/'. $rootLocationId . '/', $this->parameters['pathString']); + $subLocations = explode( '/', $subPath[1]); $locations = explode('/', $this->parameters['pathString']); - $locationId = $locations[3]; + $locationId = $subLocations[0]; // Menu will expire when top location cache expires. $response->headers->set('X-Location-Id', $locationId); diff --git a/Classes/Components/TopMenu.php b/Classes/Components/TopMenu.php index 139c1ff..831599f 100644 --- a/Classes/Components/TopMenu.php +++ b/Classes/Components/TopMenu.php @@ -26,12 +26,13 @@ public function render() { $response = new Response(); + $rootLocationId = $this->controller->getConfigResolver()->getParameter( 'content.tree_root.location_id' ); $response->setPublic(); $response->setSharedMaxAge(86400); // Menu will expire when top location cache expires. - $response->headers->set('X-Location-Id', 2); + $response->headers->set('X-Location-Id', $rootLocationId); // Menu might vary depending on user permissions, so make the cache vary on the user hash. $response->setVary('X-User-Hash'); @@ -42,7 +43,7 @@ public function render() new LocationPriority(Operator::LT, 100), ); - $list = SearchHelper::fetchChildren($this->controller, 2, $filters); + $list = SearchHelper::fetchChildren($this->controller, $rootLocationId, $filters); $pathString = ''; if (isset($this->parameters['pathString'])) { diff --git a/Classes/SearchHelper.php b/Classes/SearchHelper.php index fdfc3a2..ffdae48 100644 --- a/Classes/SearchHelper.php +++ b/Classes/SearchHelper.php @@ -100,14 +100,20 @@ public static function getPath($pathString, TuteiController $controller) { $repository = $controller->getRepository(); + $rootLocationId = $controller->getConfigResolver()->getParameter( 'content.tree_root.location_id' ); $locationService = $repository->getLocationService(); $locations = explode('/', $pathString); $path = array(); + $start = false; foreach ($locations as $id) { - - if (!in_array($id, array('', '1'))) { + if(!$start){ + if($id == $rootLocationId){ + $start = true; + } + } + if ($start and !in_array($id, array('', '1'))) { $path[] = $locationService->loadLocation($id); } }