MDL-37762: Breadcrumb not showing categories on course page
This commit is contained in:
committed by
Sam Hemelryk
parent
931eff3b84
commit
7a5f3762d0
@@ -3052,6 +3052,12 @@ class navbar extends navigation_node {
|
||||
if (!$navigationactivenode->mainnavonly) {
|
||||
$items[] = $navigationactivenode;
|
||||
}
|
||||
if ($navigationactivenode->type === self::TYPE_COURSE && $navigationactivenode->parent->key === 'currentcourse') {
|
||||
$categories = $this->get_course_categories();
|
||||
foreach ($categories as $category) {
|
||||
$items[] = $category;
|
||||
}
|
||||
}
|
||||
$navigationactivenode = $navigationactivenode->parent;
|
||||
}
|
||||
} else if ($navigationactivenode) {
|
||||
@@ -3060,6 +3066,12 @@ class navbar extends navigation_node {
|
||||
if (!$navigationactivenode->mainnavonly) {
|
||||
$items[] = $navigationactivenode;
|
||||
}
|
||||
if ($navigationactivenode->type === self::TYPE_COURSE && $navigationactivenode->parent->key === 'currentcourse') {
|
||||
$categories = $this->get_course_categories();
|
||||
foreach ($categories as $category) {
|
||||
$items[] = $category;
|
||||
}
|
||||
}
|
||||
$navigationactivenode = $navigationactivenode->parent;
|
||||
}
|
||||
} else if ($settingsactivenode) {
|
||||
@@ -3084,6 +3096,32 @@ class navbar extends navigation_node {
|
||||
return $this->items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of categories leading to this course.
|
||||
*
|
||||
* This function is used by {@link navbar::get_items()} to add back the "courses"
|
||||
* node and category chain leading to the current course. Note that this is only ever
|
||||
* called for the current course, so we don't need to bother taking in any parameters.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function get_course_categories() {
|
||||
$categories = array();
|
||||
$id = $this->page->course->category;
|
||||
while ($id) {
|
||||
$category = coursecat::get($id);
|
||||
$categories[] = new navigation_node(array(
|
||||
'text'=>$category->name,
|
||||
'shorttext'=>$category->name,
|
||||
'key'=>$category->idnumber,
|
||||
'action'=>new moodle_url('/course/category.php', array('id'=>$id))
|
||||
));
|
||||
$id = $category->parent;
|
||||
}
|
||||
$categories[] = $this->page->navigation->get('courses');
|
||||
return $categories;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new navigation_node to the navbar, overrides parent::add
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user