From 701772c0e891baad1e195fd8b1595b2828e96376 Mon Sep 17 00:00:00 2001 From: Sam Hemelryk Date: Tue, 11 Nov 2014 11:07:37 +1300 Subject: [PATCH] MDL-47434 format_topics: section 0 navigation tweak Section 0 is now only shown in the navigation block if it contains activities. If there are no activities then the section is removed. This mimicks the display on the course page. --- course/format/topics/lib.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/course/format/topics/lib.php b/course/format/topics/lib.php index aa043783809..f7e91bb8633 100644 --- a/course/format/topics/lib.php +++ b/course/format/topics/lib.php @@ -143,6 +143,19 @@ class format_topics extends format_base { // check if there are callbacks to extend course navigation parent::extend_course_navigation($navigation, $node); + + // We want to remove the general section if it is empty. + $modinfo = get_fast_modinfo($this->get_course()); + $sections = $modinfo->get_sections(); + if (!isset($sections[0])) { + // The general section is empty to find the navigation node for it we need to get its ID. + $section = $modinfo->get_section_info(0); + $generalsection = $node->get($section->id, navigation_node::TYPE_SECTION); + if ($generalsection) { + // We found the node - now remove it. + $generalsection->remove(); + } + } } /** -- 2.43.0