MDL-69588 navigation: Enable setting node visibility in secondary nav

Adds new property 'showinsecondarynavigation' and a new setter method
in the navigation_node class to enable setting the visibility of the
node in the secondary navigation.
This commit is contained in:
Mihail Geshoski 2021-06-21 10:19:10 +08:00 committed by Mathew May
parent ee63214306
commit bddc64a39d

View File

@ -151,6 +151,8 @@ class navigation_node implements renderable {
public $showinflatnavigation = false;
/** @var bool If set to true this node will be forced into a "more" menu whenever possible */
public $forceintomoremenu = false;
/** @var bool If set to true this node will be displayed in the "secondary" navigation when applicable */
public $showinsecondarynavigation = true;
/**
* Constructs a new navigation_node
@ -854,6 +856,18 @@ class navigation_node implements renderable {
}
}
/**
* Sets whether the node and its children should be displayed in the "secondary" navigation when applicable.
*
* @param bool $show
*/
public function set_show_in_secondary_navigation(bool $show = true) {
$this->showinsecondarynavigation = $show;
foreach ($this->children as $child) {
$child->set_show_in_secondary_navigation($show);
}
}
/**
* Add the menu item to handle locking and unlocking of a conext.
*