MDL-69588 navigation: Utilize showinsecondarynavigation in secondary nav

Utilizes the 'showinsecondarynavigation' property from the
navigation_node object to avoid displaying any unwanted nodes in the
secondary navigation.
This commit is contained in:
Mihail Geshoski 2021-06-21 10:26:32 +08:00 committed by Mathew May
parent bddc64a39d
commit f836887844

View File

@ -173,6 +173,7 @@ class secondary extends view {
break;
}
$this->remove_unwanted_nodes();
$this->force_nodes_into_more_menu($defaultmoremenunodes);
// Search and set the active node.
$this->scan_for_active_node($this);
@ -338,4 +339,15 @@ class secondary extends view {
$displayednodescount++;
}
}
/**
* Remove navigation nodes that should not be displayed in the secondary navigation.
*/
protected function remove_unwanted_nodes() {
foreach ($this->children as $child) {
if (!$child->showinsecondarynavigation) {
$child->remove();
}
}
}
}