Moodle | Steps to create a custom theme

|
| By Webner

In moodle we can create new theme using existing theme and customise them according to user requirements. We can create new theme from scratch or by using existing theme. We can customize their front page, course page and activity pages as per requirements. In one of the projects, we were asked to develop a new course theme using moodle default theme “clean”.

For this, we created a new clean_new theme by cloning the existing clean theme (copy the theme moodle/theme/clean and paste it outside moodle on any temp location for example).

After copying, we globally replaced the theme name ‘clean’ with ‘clean_new’ using ctrl+H in entire theme and installed the same on moodle site from siteadministartion->plugins->install plugin.

We can also replace all the instances of clean using following command from terminal in Ubuntu :

grep -rl clean /path_to_theme_folder/ | xargs sed -i 's/clean/clean_new/g'

Change the theme folder name and lang/theme_clean_new.php. After replacing the instances make the zip of theme. Select the type of plugin (in our case it is theme). Browse the zip of clean_new theme and click on install. After 3-4 seconds the clean_new theme gets installed successfully.

After installation we need to apply the new theme on site and for this we navigated to siteadministration->appearance->themeselector.

On theme selector page all available themes are displayed including clean_new theme.

Now clean_theme is ready to be customized.

We can change the layout of any page by making changes in corresponding file of theme. The main files where whole layout resides is column3.php. We can change the look and feel of theme by changing the column3 file. We can also add new css in style/custom.css file of theme.

Creating new theme by using existing theme saves the time and effort and we get the standard folder structure as well. By creating theme from scratch a developer may miss some important file or moodle coding standards may get violated. So it is always suggested to use moodle’s standard existing theme to create new customized theme.

Leave a Reply

Your email address will not be published. Required fields are marked *