← blogs.sussex.ac.uk

Moodle breadcrumb

When navigating a web site I like to know where I am so I do not feel disorientated or lost. Most web sites have a breadcrumb bar to help me with this. The metaphor is that the user has left a trail of breadcrumbs whilst traversing the site so he or she can retrace their steps, and thus originally the breadcrumb represented where a user had been on the site. In modern web sites however, the breadcrumb bar more often represents where I am in relation to the hierarchy of the site as I am as likely to have found my way to the page via a search engine. A discussion was started on Moodle.org regarding the fit for purpose of the native Moodle breadcrumb which has prompted me to blog about it here.

In our Moodle install the native breadcrumb bar looks like this when viewing a forum:

native moodle breadcrumb bar

There a number of things about the native breadcrumb that we do not like.

It does not include a link to the course section that the forum is on. It therefore doesn’t help me retrace my steps or tell me where I am in the course site.

The list of forums (sic) is a strange view of the course where I can see only the instances of forums on the site. If I were viewing another activity-type or resource-type I would have a link to a list of resources and activities of only that type. We feel this view of the site is unhelpful and that students should be seeing the activities and resources in the context that the tutor intended.

The short name of a Sussex Moodle site is concatenation of the course code and the year the course is running. As our Moodle courses are dynamically created we cannot generate a more friendly short name. We allow tutors to update the short name but they rarely do. Therefore the use of the short name in the breadcrumb bar only serves to display text which is nonsensical to the majority of students.

We have therefore made three significant customisations to the breadcrumb bar. One, we have added the course section. Two, we have removed the link to the lists of resources and activities of the same type. Three, we use the course full name. In our Moodle install the breadcrumb bar looks like this when viewing a forum:

study direct breadcrumb bar

The programmatic changes to do this were in the build_navigation function in /lib/weblib.php and in course/modedit.php. We have detailed them below.

In weblib.php at around line 3850 update:

'name' => format_string($COURSE->shortname),

to:

'name' => format_string($COURSE->fullname),

and at around line 3875 update:

$navlinks[] = array('name' => get_string('modulenameplural', $cm->modname),'link' => $CFG->wwwroot . '/mod/' . $cm->modname . '/index.php?id=' . $cm->course,'type' => 'activity');

to:

$topic = get_record('course_sections','id',$cm->section);
if (empty ($topic->name)) {
$format = ucfirst(substr($COURSE->format,0,-1));
$topic->name = "$format $topic->section";
}
$navlinks[] = array('name' => $topic->name, 'link' => "$CFG->wwwroot/course/view.php?id={$COURSE->id}&topic={$topic->section}", 'type' => 'topic');

In modedit around line 438 update:

$navlinks[] = array('name' => $strmodulenameplural, 'link' => "$CFG->wwwroot/mod/$module->name/index.php?id=$course->id", 'type' => 'activity');

to

if (empty($sectionid)) { $sectionid=$cw->id; }
$topic = get_record('course_sections','id',$sectionid);
if (empty ($topic->name)) {
$format = ucfirst(substr($COURSE->format,0,-1));
$topic->name = "$format $topic->section";
}
$navlinks[] = array(
'name' => $topic->name,
'link' => "$CFG->wwwroot/course/view.php?id={$COURSE->id}&topic={$topic->section}",
'type' => 'topic');

2 Comments