Skip to content

Commit 2845cde

Browse files
authored
keep category parameter unused if target page is set
1 parent 1a1418d commit 2845cde

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/FrontendModule/NewsCategoriesModule.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,12 @@ protected function compile(): void
4747
$container = System::getContainer();
4848
$param = $container->get(NewsCategoriesManager::class)->getParameterName();
4949

50+
// Keep the parameter unused, if a target page is set
51+
$currentPage = $GLOBALS['objPage'];
52+
$keepUnused = (int) $currentPage->id !== (int) $this->getTargetPage()->id;
53+
5054
// Get the active category
51-
if (($alias = Input::get($param)) && null !== ($activeCategory = NewsCategoryModel::findPublishedByIdOrAlias($alias))) {
55+
if (($alias = Input::get($param, false, $keepUnused)) && null !== ($activeCategory = NewsCategoryModel::findPublishedByIdOrAlias($alias))) {
5256
$this->activeCategory = $activeCategory;
5357

5458
// Set the canonical URL
@@ -57,7 +61,7 @@ protected function compile(): void
5761
if ($responseContext->has(HtmlHeadBag::class)) {
5862
/** @var HtmlHeadBag $htmlHeadBag */
5963
$htmlHeadBag = $responseContext->get(HtmlHeadBag::class);
60-
$htmlHeadBag->setCanonicalUri($GLOBALS['objPage']->getAbsoluteUrl());
64+
$htmlHeadBag->setCanonicalUri($currentPage->getAbsoluteUrl());
6165
}
6266
}
6367
}

0 commit comments

Comments
 (0)