Note:

If you want to create a new page for developers, you should create it on the Moodle Developer Resource site.

Theme upgrade notes

From MoodleDocs


Warning: This page is no longer in use. The information contained on the page should NOT be seen as relevant or reliable.


As the project evolves, theme designers and maintainers should take care that their themes accommodate functionality additions and changes.

Moodle 2.9

Moodle 2.9 has made some alterations to the user navigation. As such, certain areas of Moodle are only accessable from the user menu ('My profile', 'messages', 'preferences'). To access these areas, themes will need to implement the user menu, or equivalent navigation of your own.

Moodle 2.8

Moodle 2.8 contains large changes, including but not limited to

  • an all-new user menu, and
  • an overhauled gradebook.

These changes bring with them new considerations for theme developers, who will need to adjust their themes accordingly.

User menu

The user menu is a new renderer function - $OUTPUT->user_menu() - that leverages the action_menu renderable to create a dropdown menu containing user-centric links (my home, my profile, etc). The user menu encapsulates the same status checks and exposes the same information as the existing $OUTPUT->login_info() function, with the addition of user pictures.

It is important to note that the user menu depends upon a new function in /user/lib.php, entitled user_get_user_navigation_info. It is possible for the upgrade step to fail if $CFG->dirroot is overridden by a site's config.php incorrectly.

Including the user menu in a backwards-compatible way

As this is a new feature for 2.8, you may want to build your theme such that it falls back to use $OUTPUT->login_info if the user menu is not present, e.g.

<?php
if (method_exists($OUTPUT, 'user_menu')) {
  echo $OUTPUT->user_menu(); // user menu, for Moodle 2.8
} else {
  echo $OUTPUT->login_info(); // login_info, Moodle 2.7 and before
}
?>

This will allow you to write a theme that works on both 2.8 and on previous versions of Moodle.

Styling edge cases

When styling the user menu, it is important to cover additional use cases under which the user menu changes. These are:

  • when Javascript is disabled
  • when a user is "logged in as" another user
  • when a user is using a right-to-left language

Ensure any custom styles you write take into account these circumstances; for reference you may wish to consult the existing styles, which are in /theme/bootstrapbase/less/moodle/modules.less.

Grader report

The new grader report is a significant change from its predecessor (please see [1]) and may require some adjustments to your theme.

Overflowing

Put simply, the grader report now expects to be directly on the page, overflowing the window bounds if necessary - as the user scrolls more of the table into view, floating row and column headers appear and move with the window to provide context as to their position in the table.

This has unfortunate effects on themes where the grader report is situated within an element with the overflow: hidden rule set, or with a value provided for width or max-width. In order to use the new grader report as designed, allow it to spill out unconstrained - the floating headers will not kick in otherwise and pose a usability concern.