Moodle deprecation warnings -> navigation bar | build_navigation()

Published: Mon 17 May 2010

In Tech.

tags: moodle

Over the week-end I rediscovered Moodle's DEVELOPER debug setting which surfaced many unpleasant warnings. The first kind was removed by following proper programming practices (ahem), the second kind involved a couple of deprecation warnings that reminded me that Moodle is slowly and surely making its way toward 2.0. I filed a bug about this against DVReport, I should be looking into that one over the summer (Moodle 2.0 release date is July 20th! It's so strange to see an actual date, after years of reading about the preparations. Sounds awesome :))

The old navigation bar, pre-1.9.8 I assume though I'm not sure when it was deprecated, used to look like this:

$navigation = '<a href="$url">$block_name</a> -> $action_name';

The "->" would indicate a separation between 2 links, and automatically generate a nice triangle picture in the breadcrumb.

DVReport screenshot of the navigation bar

With the new navigation style, you get to split up the different sections into different arrays. It might seem more cumbersome but I think in the end it's neater, because you get to make a distinction between every element of the navigation, as opposed to one long messy string where you can easily miss the arrows when reading. The visual output is the same.

$navigation = build_navigation(array(
        array('name' => $block_name,
            'link' => $url,
            'type' => 'title'),
        array('name' => $action_name,
            'link' => '',
            'type' => 'title')
        )
    );

The only meh thing about this is that "type" isn't really documented. The phpdoc comment reads "this really needs to be documented better" and lists a few values. As usual, there isn't one that quite fits what DVReport does, because DVReport is a block, not an activity or course module. So I picked 'title', which seems innocent enough -- we'll see what future updates to the core navigation bar code make out of that!

links

social