Hi
Background
We have developed a Moodle plugin (we call it “the portal”) that displays a set of custom pages. These pages are built to look like standard Moodle pages, complete with header, footer, and Moodle custom menus. The theme we use is a customised clone of "Clean", and we add custom menus via renderers.php.
The Problem
The custom menus no longer work on our portal pages. When we click on a top level menu item, we see something like #cm_submenu_x appended to the URL, but the submenu doesn’t open. (Top-level Menu links still work if they don’t contain a sub-menu.) However, the menus do work correctly for all standard Moodle pages, and so I don't think this is a problem with the theme per se.
I suspect that in building our portal pages, we have missed something important! But what? I’m at a loss to work out what’s gone wrong!
Here's a screen shot of what happens when a menu is clicked on a Portal page (note the URL):
And here's what happens on standard Moodle pages:
Observations
- The submenu items are visible in the code when "View page source" is selected.
- The debug panel in Chrome doesn’t reveal any JavaScript bugs or warnings.
- The problem occurs in latest versions of Chrome, Firefox and IE.
- The problem also occurs with the unaltered “Clean” theme. The problem does not occur with non-bootstrap themes.
- The menus were working on custom pages in a previous version of Moodle with a non-bootstrap theme.
- We first noticed this problem after upgrading to Moodle 2.6 from an earlier 2.6 release candidate or beta. We’re currently using Moodle 2.6.1+ (Build: 20140117).
More Info
All our custom portal pages include the following:
$PAGE->set_context( context_system::instance() );
$PAGE->set_pagelayout('base');
$PAGE->set_title( $pagetitle ); // $pagetitle is a simple string
$PAGE->set_heading( $blockname ); // $blockname is a simple string
$PAGE->set_focuscontrol('');
$PAGE->set_cacheable(true);
$PAGE->navbar->ignore_active(); // Clear any existing navigation settings
$PAGE->navbar->add($homepagename,
new moodle_url( $CFG->wwwroot . '/course/view.php?id=' . $homepageid ) );
// Campus name and campus home page course ID for current user
$PAGE->navbar->add( $alinks[$i]['name'], $alinks[$i]['url'] );
// The above sits in a loop and builds the breadcrumb from items stored in the $alinks array
$OUTPUT->header();
Maybe I’ve missed or misused something?? Some of our code is now a couple of years old so maybe we've overlooked a change introduced in recent Moodle versions??
I’d be very grateful if anyone could show me where we might have gone wrong, or suggest a way to fix this issue.
Thanks!
David