Customizing Boost from a child theme

Customizing Boost from a child theme

by Alberto PM -
Number of replies: 9

Hello.

I'm working with Moodle 3.2.2, the Boost theme an a child theme that extends Boost.

I'm a newbie in theming and I try to make some little changes in Boost theme appearence using a child theme.

According with the information at https://docs.moodle.org/dev/Creating_a_theme_based_on_boost, I've created the minimun folders and files required.

Let's say I want to change the login page.I don't know what files I must include in my theme folder to override the mustache template from Boost.
This is what I've done till now.

  1. I've changed my config file, so the code is the one showed below.
  2. I've created a layout folder and included the same login.php file as in Boost (I think this is not necesary, isn't it?)
  3. I've created a template folder and included only the login.mustache file, where I supose I must do the changes.
 

config.php 

name = 'dom'; $THEME->sheets = []; $THEME->editor_sheets = []; $THEME->parents = ['boost']; $THEME->layouts = [ 'login' => array( 'file' => 'login.php', 'regions' => array(), 'options' => array('langmenu' => false), ), ]; $THEME->enable_dock = false; $THEME->yuicssmodules = array(); $THEME->rendererfactory = 'theme_overridden_renderer_factory'; $THEME->requiredblocks = ''; $THEME->addblockposition = BLOCK_ADDBLOCK_POSITION_FLATNAV;


I supose when working with child themes I must only add in my theme folder the files that I need to change, isn't it?

I'll appreciate so much if anybody could tell me what are the files that I must include in my theme folder.

BTW, I've been taking a look at Waxed and Fordson themes. They are great! But I can't find the way they override something like this.

Thanks in advance!

Average of ratings: -
In reply to Alberto PM

Re: Customizing Boost from a child theme

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

It really depends what you want to change Alberto.

Do you need to make changes that affect the php/html of the layout itself, or are your changes restricted to css/styling or layout changes that can be made with css rather than changes to the html structure?


Richard

In reply to Richard Oelmann

Re: Customizing Boost from a child theme

by Alberto PM -

Hello!

Thanks for your reply, Richard!

I want to make changes that affect the php/html of the layout, yes. I supose I must play with the mustache files, but I don't know wich files must I copy to my theme folder to do that. For example, to make changes in the login layout.


Regards.

In reply to Alberto PM

Re: Customizing Boost from a child theme

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

Hi Alberto,

The main login page is constructed by the boost/templates/core/login.mustache file, so you would need to copy that to your custom theme and edit it as required.

It's actually called from a function in boost/classes/output/core_renderer.php but there's no need to copy and edit that as it will pick up the edited template from your own theme anyway.

Richard


Average of ratings: Useful (2)
In reply to Richard Oelmann

Re: Customizing Boost from a child theme

by Alberto PM -

Hi Richard!

I think I got it.

I was working with login.mustache file but the one in template folder, no the one in template/core folder. That's was the problem.

By the way, what the one in the template folder does?


Thanks a lot! 

In reply to Alberto PM

Re: Customizing Boost from a child theme

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

Hi Alberto 

Depending on exactly what you want to do, you may actually need both of them. 

The one in the main template folder (and it's php equivalent in the layout folder) are responsible for constructing the whole page. But as part of that it calls 'main_content'. 

As part of that main content, Boost calls a function (render_login) which calls the template file in templates/core. And that controls what you actually see most of the time on a standard login page. 

That might be a slightly simplistic explanation (I'm on my phone so no access to check the code right now) but I think from memory it's an outline of the difference between the two and how  they work together smile 

Richard 

Average of ratings: Useful (2)
In reply to Richard Oelmann

Re: Customizing Boost from a child theme

by Alberto PM -

Hi Richard!


Your explanation helps me to understand a little bit more how moodle works.

One more thing, do you know about any documentation explaining how Moodle manage all of these files? 
That definitely would help me to get known about this.


Thanks a lot!


In reply to Alberto PM

Re: Customizing Boost from a child theme

by Richard Oelmann -
Picture of Core developers Picture of Plugin developers Picture of Testers
re documentation - at that level and around the details of Boost using templates, no not really - other than the Boost theme itself.
There is the documentation around the Photo child theme - but it only goes into new settings and doesn't mention templates and renderers and mustache etc.
There's also the page that explains mustache https://docs.moodle.org/dev/Templates but personally, I'm learning more about it all the time simply by answering queries like yours and looking at the Boost theme itself and how it works smile

R
In reply to Richard Oelmann

Re: Customizing Boost from a child theme

by Alberto PM -

Hi Richard and Mary!

Sorry for taking time to answer...

I agree with you! If there isn't any documentation about it maybe the best way is to take a look at the forum and at the Boost theme itself to know how it works.


Thanks a lot for your suggestions!