Skip to content

Commit

Permalink
Ignore the query string when marking pages as "active" (see #480)
Browse files Browse the repository at this point in the history
  • Loading branch information
leofeyer committed May 15, 2019
1 parent c93a0e4 commit 441bf0a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/Resources/contao/modules/Module.php
Expand Up @@ -367,8 +367,11 @@ protected function renderNavigation($pid, $level=1, $host=null, $language=null)
$row = $objSubpage->row();
$trail = \in_array($objSubpage->id, $objPage->trail);

// Use the path without query string to check for active pages (see #480)
list($path) = explode('?', \Environment::get('request'), 2);

// Active page
if (($objPage->id == $objSubpage->id || ($objSubpage->type == 'forward' && $objPage->id == $objSubpage->jumpTo)) && !($this instanceof ModuleSitemap) && $href == \Environment::get('request'))
if (($objPage->id == $objSubpage->id || ($objSubpage->type == 'forward' && $objPage->id == $objSubpage->jumpTo)) && !($this instanceof ModuleSitemap) && $href == $path)
{
// Mark active forward pages (see #4822)
$strClass = (($objSubpage->type == 'forward' && $objPage->id == $objSubpage->jumpTo) ? 'forward' . ($trail ? ' trail' : '') : 'active') . (($subitems != '') ? ' submenu' : '') . ($objSubpage->protected ? ' protected' : '') . (($objSubpage->cssClass != '') ? ' ' . $objSubpage->cssClass : '');
Expand Down
5 changes: 4 additions & 1 deletion src/Resources/contao/modules/ModuleCustomnav.php
Expand Up @@ -152,8 +152,11 @@ protected function compile()

$trail = \in_array($objModel->id, $objPage->trail);

// Use the path without query string to check for active pages (see #480)
list($path) = explode('?', \Environment::get('request'), 2);

// Active page
if ($objPage->id == $objModel->id && $href == \Environment::get('request'))
if ($objPage->id == $objModel->id && $href == $path)
{
$strClass = trim($objModel->cssClass);
$row = $objModel->row();
Expand Down

0 comments on commit 441bf0a

Please sign in to comment.