Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Commit

Permalink
Added $item['isTrail'] to the navigation menu templates (see #7096)
Browse files Browse the repository at this point in the history
  • Loading branch information
leofeyer committed Sep 5, 2014
1 parent 866b044 commit d74d58a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
3 changes: 3 additions & 0 deletions system/docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ Contao Open Source CMS changelog
Version 3.4.0-beta1 (2014-10-XX)
--------------------------------

### New
Added `$item['isTrail']` to the navigation menu templates (see #7096).

### Improved
Handle `data-` and `ng-` attributes in `Widget::addAttributes()` (see #7095).

Expand Down
7 changes: 5 additions & 2 deletions system/modules/core/modules/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -314,20 +314,22 @@ protected function renderNavigation($pid, $level=1, $host=null, $language=null)
}

$row = $objSubpages->row();
$trail = in_array($objSubpages->id, $objPage->trail);

// Active page
if (($objPage->id == $objSubpages->id || $objSubpages->type == 'forward' && $objPage->id == $objSubpages->jumpTo) && !$this instanceof \ModuleSitemap && !\Input::get('articles'))
{
// Mark active forward pages (see #4822)
$strClass = (($objSubpages->type == 'forward' && $objPage->id == $objSubpages->jumpTo) ? 'forward' . (in_array($objSubpages->id, $objPage->trail) ? ' trail' : '') : 'active') . (($subitems != '') ? ' submenu' : '') . ($objSubpages->protected ? ' protected' : '') . (($objSubpages->cssClass != '') ? ' ' . $objSubpages->cssClass : '');
$strClass = (($objSubpages->type == 'forward' && $objPage->id == $objSubpages->jumpTo) ? 'forward' . ($trail ? ' trail' : '') : 'active') . (($subitems != '') ? ' submenu' : '') . ($objSubpages->protected ? ' protected' : '') . (($objSubpages->cssClass != '') ? ' ' . $objSubpages->cssClass : '');

$row['isActive'] = true;
$row['isTrail'] = false;
}

// Regular page
else
{
$strClass = (($subitems != '') ? 'submenu' : '') . ($objSubpages->protected ? ' protected' : '') . (in_array($objSubpages->id, $objPage->trail) ? ' trail' : '') . (($objSubpages->cssClass != '') ? ' ' . $objSubpages->cssClass : '');
$strClass = (($subitems != '') ? 'submenu' : '') . ($objSubpages->protected ? ' protected' : '') . ($trail ? ' trail' : '') . (($objSubpages->cssClass != '') ? ' ' . $objSubpages->cssClass : '');

// Mark pages on the same level (see #2419)
if ($objSubpages->pid == $objPage->pid)
Expand All @@ -336,6 +338,7 @@ protected function renderNavigation($pid, $level=1, $host=null, $language=null)
}

$row['isActive'] = false;
$row['isTrail'] = $trail;
}

$row['subitems'] = $subitems;
Expand Down
6 changes: 5 additions & 1 deletion system/modules/core/modules/ModuleCustomnav.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,16 @@ protected function compile()
break;
}

$trail = in_array($arrPage['id'], $objPage->trail);

// Active page
if ($objPage->id == $arrPage['id'])
{
$strClass = trim($arrPage['cssClass']);
$row = $arrPage;

$row['isActive'] = true;
$row['isTrail'] = false;
$row['class'] = trim('active ' . $strClass);
$row['title'] = specialchars($arrPage['title'], true);
$row['pageTitle'] = specialchars($arrPage['pageTitle'], true);
Expand All @@ -194,10 +197,11 @@ protected function compile()
// Regular page
else
{
$strClass = trim($arrPage['cssClass'] . (in_array($arrPage['id'], $objPage->trail) ? ' trail' : ''));
$strClass = trim($arrPage['cssClass'] . ($trail ? ' trail' : ''));
$row = $arrPage;

$row['isActive'] = false;
$row['isTrail'] = $trail;
$row['class'] = $strClass;
$row['title'] = specialchars($arrPage['title'], true);
$row['pageTitle'] = specialchars($arrPage['pageTitle'], true);
Expand Down

0 comments on commit d74d58a

Please sign in to comment.