Skip to content

Commit

Permalink
MDL-69588 navigation: Enable setting node visibility in secondary nav
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Mihail Geshoski authored and Chocolate-lightning committed Aug 23, 2021
1 parent ee63214 commit bddc64a
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/navigationlib.php
Expand Up @@ -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
Expand Down Expand Up @@ -854,6 +856,18 @@ public function set_force_into_more_menu(bool $forceintomoremenu = false) {
}
}

/**
* 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.
*
Expand Down

0 comments on commit bddc64a

Please sign in to comment.