From d2c83565d9d9409d6a622648f1e4663065c746a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luca=20B=C3=B6sch?= Date: Mon, 8 May 2023 07:09:21 +0200 Subject: [PATCH] MDL-78138 theme_boost: Reliably remove TYPE_CATEGORY breadcrumbs. --- theme/boost/classes/boostnavbar.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/theme/boost/classes/boostnavbar.php b/theme/boost/classes/boostnavbar.php index bd33f611b659c..c438148375923 100644 --- a/theme/boost/classes/boostnavbar.php +++ b/theme/boost/classes/boostnavbar.php @@ -73,8 +73,11 @@ protected function prepare_nodes_for_boost(): void { // Remove 'My courses' and 'Courses' if we are in the course context. $this->remove('mycourses'); $this->remove('courses'); - // Remove the course category breadcrumb node. - $this->remove($this->page->course->category, \breadcrumb_navigation_node::TYPE_CATEGORY); + // Remove the course category breadcrumb nodes. + foreach ($this->items as $key => $item) { + // Remove if it is a course category breadcrumb node. + $this->remove($item->key, \breadcrumb_navigation_node::TYPE_CATEGORY); + } // Remove the course breadcrumb node. $this->remove($this->page->course->id, \breadcrumb_navigation_node::TYPE_COURSE); // Remove the navbar nodes that already exist in the secondary navigation menu. @@ -103,8 +106,11 @@ protected function prepare_nodes_for_boost(): void { if ($this->page->context->contextlevel == CONTEXT_MODULE) { $this->remove('mycourses'); $this->remove('courses'); - // Remove the course category breadcrumb node. - $this->remove($this->page->course->category, \breadcrumb_navigation_node::TYPE_CATEGORY); + // Remove the course category breadcrumb nodes. + foreach ($this->items as $key => $item) { + // Remove if it is a course category breadcrumb node. + $this->remove($item->key, \breadcrumb_navigation_node::TYPE_CATEGORY); + } $courseformat = course_get_format($this->page->course)->get_course(); // Section items can be only removed if a course layout (coursedisplay) is not explicitly set in the // given course format or the set course layout is not 'One section per page'.