Boost Mustache Templates - Moodle 3.7

Boost Mustache Templates - Moodle 3.7

by Dave Emsley -
Number of replies: 4

Hi there, hoping someone can explain the use of templates when creating a child theme.

I have my own child theme but want to customise the login page.

I compied :

  • boost/layout/login.php
  • boost/templates/login.mustache
  • boost/templates/core/loginform.mustache  to my theme folder.
It's obvious how I edit the first two; and have done so successfully but where does the templates/core/loginform.mustache get called from and how can I ensure the one from my theme is picked up please?

Cheers

Dave


Average of ratings: -
In reply to Dave Emsley

Re: Boost Mustache Templates - Moodle 3.7

by Andreas Grabs -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Translators
Hi Dave,

you have to override the "layout/login.php" in your theme especially the part:
echo $OUTPUT->render_from_template('theme_boost/login', $templatecontext);
change to
echo $OUTPUT->render_from_template('theme_your_theme/login', $templatecontext);

Best regards
Andreas
Average of ratings: Useful (1)
In reply to Andreas Grabs

Re: Boost Mustache Templates - Moodle 3.7

by Dave Emsley -
Hi Andreas, Thanks for the response but I've don't that. That only refered to the login.mustache template and not to the /templates/core/loginform.mustache

Cheers
Dave
In reply to Dave Emsley

Re: Boost Mustache Templates - Moodle 3.7

by Andreas Grabs -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Translators

Hi Dave,

if you have a file "templates/core/loginform.mustache" in your theme then all is fine. If you also want to override the "templates/login.mustache" you need a file "templates/theme_boost/login.mustache"

That's the way templates work in moodle. In general you have to place a template in a folder with the full component name and in it the "mustache" file you want to override.

The loginform is a core component so the path in your theme is "templates/core/loginform.mustache"
The login.mustache comes from boost so the path is "templates/theme_boost/login.mustache"

Moodle look for templates in the following order.

  1. Current theme
  2. Parent theme of the current theme
  3. Component

What is found first will be used.

If you want to modify the context data that goes into the login.mustache you can override the file "layout/login.php" in the way I described in the last post.

Best regards
Andreas

Average of ratings: Useful (1)
In reply to Andreas Grabs

Re: Boost Mustache Templates - Moodle 3.7

by web dev -
Hi Gents,

apologies for barging in here...i am in a way in this theme limbo also.

i have struggled to find anything more linear in instructions or better than what Dave and Andreas have provided above.

i have also tried to modify Boost Campus with somewhat limited success (this just involved removing some list item elements to remove the Timeline tab from the Overview page) and want to create and modify a theme template the correct way.

Dave may i get some insight on how you went about creating the theme and where you placed the folders and files etc?

My main goal for the Overview page is to remove the Timeline tab and keep the Courses tab but only show the course available and do away with In progress, Future and Past course buttons altogether.

TIA
wd