Theme plugins
A Moodle theme allows users to customize the appearance and functionality of their Moodle site, from overall design to specific activities. Users can create their own themes or modify existing ones, leveraging CSS and JavaScript for customization. The theme architecture ensures smooth fallbacks for minimal changes, fostering flexibility and ease of use.
File structure
Theme plugins are located in the /theme
directory.
Each plugin is in a separate subdirectory and consists of a number of mandatory files and any other files the developer is going to use.
View an example directory layout for a theme_example
plugin.
theme/example
|-- amd
| └-- src
|-- classes
| └-- output
|-- fonts
|-- fonts_core
|-- fonts_plugins
| └-- plugintype
| └-- pluginname
|-- lang
| └-- en
| └-- theme_example.php
|-- layout
|-- pix
| └-- favicon.ico
| └-- screenshot.png
|-- pix_plugins
| └-- plugintype
| └-- pluginname
|-- style
|-- scss
|-- templates
|-- config.php
|-- settings.php
└-- version.php
Some of the important files for the Theme plugintype are described below. See the common plugin files documentation for details of other files which may be useful in your plugin.
You can customize icons in base themes:
- Without altering core code by placing them in
$CFG->dataroot/pix
and$CFG->dataroot/pix_plugins
. If a theme extends a base theme and includes its own icons, those will take precedence. - Adding custom icons to a theme by placing them in the theme's
pix_core
andpix_plugins
directories, as described in the Override images section.
Similarly, mustache templates in base themes can be overridden without impacting core code by placing them in templates/[componentname]/[templatename].mustache
.