From bddc64a39d5fdf662984212cbcfa7f4b8402ef08 Mon Sep 17 00:00:00 2001 From: Mihail Geshoski Date: Mon, 21 Jun 2021 10:19:10 +0800 Subject: [PATCH] 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. --- lib/navigationlib.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/navigationlib.php b/lib/navigationlib.php index eb97151053a..f682557d63f 100644 --- a/lib/navigationlib.php +++ b/lib/navigationlib.php @@ -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 @@ -855,6 +857,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. * * @param \navigation_node $node Node to add -- 2.11.4.GIT