How to override a Boost template file in child theme?

How to override a Boost template file in child theme?

by Olly Pethick -
Number of replies: 12

This may be a stupid question but I'm new to Moodle and can't seem to override a template file of my boost parent theme.

All I want to do is change a couple of things in "header.mustache" file to show in my boost child theme, without altering the original template file in boost.

I'm also not sure how the layouts folder is involved in all this, any tutorials I have found seem to be different than my version of Moodle.

Any help would be much appreciated.


Moodle version: 3.4.1

Parent theme: Boost, Version: 2017111300

Child theme: LSU




Average of ratings: -
In reply to Olly Pethick

Re: How to override a Boost template file in child theme?

by Rick Jerz -
Picture of Particularly helpful Moodlers Picture of Testers

I don't know if this will help, but I did give this presentation about modifying Boost at several Moodlemoots last year.

In reply to Rick Jerz

Re: How to override a Boost template file in child theme?

by Olly Pethick -

Hi thanks for your help, I need to know how to override the mustache files, I'm am fine with overriding the CSS.

In reply to Olly Pethick

Re: How to override a Boost template file in child theme?

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

A search with a well known search engine with "moodle templates" gives: https://docs.moodle.org/dev/Templates#How_to_I_override_a_template_in_my_theme.3F.

Average of ratings: Useful (1)
In reply to Gareth J Barnard

Re: How to override a Boost template file in child theme?

by Olly Pethick -

I have searched, however copying the altered template file into the new 'templates' directory in my theme does not work, neither when its just "templates/header.mustache" or "templates/mod_header/header.mustache".

In reply to Olly Pethick

Re: How to override a Boost template file in child theme?

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

An educated guess indicates to override columns2.mustache (etc.) and change '{{>theme_boost/header}}' as appropriate then override the layout files (i.e. columns2.php) and change 'echo $OUTPUT->render_from_template('theme_boost/columns2', $templatecontext);' as appropriate.

In reply to Gareth J Barnard

Re: How to override a Boost template file in child theme?

by Olly Pethick -

I don't have a columns2.mustache file. This is what's been confusing me, what is the purpose of the columns2 file? And why do I override that over say the columns1 file? Sorry for my ignorance I am new to this.

In reply to Olly Pethick

Re: How to override a Boost template file in child theme?

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers
In reply to Gareth J Barnard

Re: How to override a Boost template file in child theme?

by Olly Pethick -

Thanks I will give these a read.

In reply to Gareth J Barnard

Re: How to override a Boost template file in child theme?

by Olly Pethick -

Thanks I followed this and it's all working correctly!

In reply to Olly Pethick

Re: How to override a Boost template file in child theme?

by Richard Oelmann -
Picture of Core developers Picture of Plugin developers Picture of Testers

Is LSU a publicly available theme for us to look at or is it commercial or your own development? I don't seem to be able to find it in a search anywhere.

In reply to Olly Pethick

Trả lời: How to override a Boost template file in child theme?

by Anh Tạ -

For anyone who finding the way to override boost theme templates from child theme. Do 2 step below.

  1. Just create a folder in your theme folder name {yourtheme}/templates/theme_boost 
  2. Create mustache file with the same name with the one you want to override.
Eg: If you want to override login.mustache, just create {yourtheme}/templates/theme_boost/login.mustache
Average of ratings: Useful (4)