Skip to content

Commit

Permalink
MDL-47434 format_topics: section 0 navigation tweak
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Sam Hemelryk committed Nov 13, 2014
1 parent f974525 commit 701772c
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions course/format/topics/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,19 @@ public function extend_course_navigation($navigation, navigation_node $node) {

// 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();
}
}
}

/**
Expand Down

0 comments on commit 701772c

Please sign in to comment.