MDL-72287 theme_boost: Remove the breadcrumb for course context.

This commit is contained in:
abgreeve 2021-08-05 13:59:52 +08:00 committed by Mihail Geshoski
parent 5ee0b620ae
commit b9d1aaaa3e
2 changed files with 13 additions and 4 deletions

View File

@ -27,14 +27,17 @@ class boostnavbar implements \renderable {
/** @var array The individual items of the navbar. */
protected $items = [];
/** @var moodle_page The current moodle page. */
protected $page;
/**
* Takes a navbar object and picks the necessary parts for display.
*
* @param \navbar $navbar The navigation bar.
* @param \moodle_page $page The current moodle page.
*/
public function __construct(\navbar $navbar) {
foreach ($navbar->get_items() as $item) {
public function __construct(\moodle_page $page) {
$this->page = $page;
foreach ($this->page->navbar->get_items() as $item) {
$this->items[] = $item;
}
$this->prepare_nodes_for_boost();
@ -46,6 +49,12 @@ class boostnavbar implements \renderable {
protected function prepare_nodes_for_boost(): void {
global $PAGE;
// Don't show the navigation if we are in the course context.
if ($this->page->context->contextlevel == CONTEXT_COURSE) {
$this->clear_items();
return;
}
$this->remove('myhome'); // Dashboard.
$this->remove('home');

View File

@ -53,7 +53,7 @@ class core_renderer extends \core_renderer {
* @return string the HTML for the navbar.
*/
public function navbar(): string {
$newnav = new \theme_boost\boostnavbar($this->page->navbar);
$newnav = new \theme_boost\boostnavbar($this->page);
return $this->render_from_template('core/navbar', $newnav);
}