mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
MDL-39127 navigation: fixed loading of categories for navbar
This commit is contained in:
parent
9aae7551ec
commit
2fb77a96b3
@ -3061,14 +3061,26 @@ class navbar extends navigation_node {
|
||||
*/
|
||||
private function get_course_categories() {
|
||||
$categories = array();
|
||||
$id = $this->page->course->category;
|
||||
while ($id) {
|
||||
$category = coursecat::get($id);
|
||||
$url = new moodle_url('/course/index.php', array('categoryid' => $id));
|
||||
$categories[] = navigation_node::create($category->get_formatted_name(), $url, self::TYPE_CATEGORY, null, $id);
|
||||
foreach ($this->page->categories as $category) {
|
||||
$url = new moodle_url('/course/index.php', array('categoryid' => $category->id));
|
||||
$name = format_string($category->name, true, array('context' => context_coursecat::instance($category->id)));
|
||||
$categories[] = navigation_node::create($name, $url, self::TYPE_CATEGORY, null, $category->id);
|
||||
$id = $category->parent;
|
||||
}
|
||||
$categories[] = $this->page->navigation->get('courses');
|
||||
if (is_enrolled(context_course::instance($this->page->course->id))) {
|
||||
$courses = $this->page->navigation->get('mycourses');
|
||||
} else {
|
||||
$courses = $this->page->navigation->get('courses');
|
||||
}
|
||||
if (!$courses) {
|
||||
// Courses node may not be present.
|
||||
$courses = navigation_node::create(
|
||||
get_string('courses'),
|
||||
new moodle_url('/course/index.php'),
|
||||
self::TYPE_CONTAINER
|
||||
);
|
||||
}
|
||||
$categories[] = $courses;
|
||||
return $categories;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user