MDL-72652 theme_boost: Reimplement navbar in site administration

Reimplements the navbar in the site administration pages and removes
any navbar nodes that are already present in the primary or secondary
navigation menu.
This commit is contained in:
Mihail Geshoski 2021-10-19 10:10:36 +08:00
parent 385938b472
commit 10a91df9e3

View File

@ -44,15 +44,23 @@ class boostnavbar implements \renderable {
* Prepares the navigation nodes for use with boost.
*/
protected function prepare_nodes_for_boost(): void {
// Don't display the navbar if we are in the site navigation.
if (!is_null($this->get_item('root'))) {
$this->clear_items();
return;
}
global $PAGE;
$this->remove('myhome'); // Dashboard.
$this->remove('home');
if (!is_null($this->get_item('root'))) { // We are in site administration.
// Remove the 'Site administration' navbar node as it already exists in the primary navigation menu.
$this->remove('root');
// Loop through the remaining navbar nodes and remove the ones that already exist in the secondary
// navigation menu.
foreach ($this->items as $item) {
if ($PAGE->secondarynav->get($item->key)) {
$this->remove($item->key);
}
}
}
// Set the designated one path for courses.
$mycoursesnode = $this->get_item('mycourses');
if (!is_null($mycoursesnode)) {