Skip to content

Commit 3d84715

Browse files
author
Hubert Prein
committed
Option to ignore active childs for nodes
1 parent 13bfa5e commit 3d84715

File tree

3 files changed

+23
-17
lines changed

3 files changed

+23
-17
lines changed

AmNavPlugin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function getName()
2020

2121
public function getVersion()
2222
{
23-
return '1.6.7';
23+
return '1.6.8';
2424
}
2525

2626
public function getDeveloper()

services/AmNavService.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,9 +620,14 @@ private function _buildNavHtml($nodes, $parentId = 0, $level = 1)
620620
if ($children) {
621621
$nodeClasses[] = $this->_getParam('classChildren', 'has-children');
622622
}
623-
if ($this->_isNodeActive($node) || $this->_isChildActive($nodes, $node['id'])) {
623+
if ($this->_isNodeActive($node)) {
624624
$nodeClasses[] = $this->_getParam('classActive', 'active');
625625
}
626+
if ($this->_getParam('ignoreActiveChilds', false) === false) {
627+
if ($this->_isChildActive($nodes, $node['id']) && ! in_array($this->_getParam('classActive', 'active'), $nodeClasses)) {
628+
$nodeClasses[] = $this->_getParam('classActive', 'active');
629+
}
630+
}
626631
if ($level == 1 && $count == 1) {
627632
$nodeClasses[] = $this->_getParam('classFirst', 'first');
628633
}

variables/AmNavVariable.php

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,21 @@ public function getName()
2222
* @param array $params
2323
*
2424
* Params possibilities:
25-
* - id ID for the navigation UL.
26-
* - class Class name for the navigation UL.
27-
* - classActive Class name for the active nodes.
28-
* - classBlank Class name for hyperlinks that have a _blank target.
29-
* - classLevel2 Class name for the children UL. You can add a classLevel for every level you need (e.g.: classLevel2, classLevel3).
30-
* - classChildren Class name for a node that has children.
31-
* - classFirst Class name for the first node in the navigation.
32-
*
33-
* - linkRel Rel (relationship) for each hyperlink.
34-
*
35-
* - excludeUl Exclude the main UL wrapper.
36-
* - maxLevel Build the navigation till a certain level.
37-
* - overrideStatus Includes every node whatever the status.
38-
* - startFromId Begin the navigation at a specific node ID.
25+
* - id ID for the navigation UL.
26+
* - class Class name for the navigation UL.
27+
* - classActive Class name for the active nodes.
28+
* - classBlank Class name for hyperlinks that have a _blank target.
29+
* - classLevel2 Class name for the children UL. You can add a classLevel for every level you need (e.g.: classLevel2, classLevel3).
30+
* - classChildren Class name for a node that has children.
31+
* - classFirst Class name for the first node in the navigation.
32+
*
33+
* - linkRel Rel (relationship) for each hyperlink.
34+
*
35+
* - excludeUl Exclude the main UL wrapper.
36+
* - maxLevel Build the navigation till a certain level.
37+
* - overrideStatus Includes every node whatever the status.
38+
* - startFromId Begin the navigation at a specific node ID.
39+
* - ignoreActiveChilds Won't make a node active if a node's child is active.
3940
*
4041
* @return string
4142
*/
@@ -129,4 +130,4 @@ public function getBreadcrumbs($params = array())
129130
{
130131
return craft()->amNav->getBreadcrumbs($params);
131132
}
132-
}
133+
}

0 commit comments

Comments
 (0)