Changing the front page from a Boost's child theme

Changing the front page from a Boost's child theme

by Alberto PM -
Number of replies: 7

Hello.

In line with this topic I'm looking for a way to change the front page of child theme of Boost.

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


Let's say I wanna change the site name by the logo in the navbar, remove the page header, or put some information at footer (for example working with 3 columns, due to Boostrap integration).

What files should I considerer to work with?


BTW, I was trying to remove the dropdown item for selecting language with this code in my config.php file:

$THEME->layouts = [ 'frontpage' => array( 'file' => 'columns2.php', 'regions' => array('side-pre'), 'defaultregion' => 'side-pre', 'options' => array('nonavbar' => true, langmenu=false), ) ]; 


but it doesn't work. I don't know if I'm doing something wrong or if I shouldn't modify it there.
(I don't wanna hide it using SCSS).


Thanks in advance!

Average of ratings: -
In reply to Alberto PM

Re: Changing the front page from a Boost's child theme

by Chris Kenniburg -
Picture of Particularly helpful Moodlers Picture of Plugin developers

In a child theme when you utilize a layout there are actually three areas to address: 

  • config.php
  • layout/name of file.php
  • templates/template.mustache that the layout file points to.


Here is my config for a boost child theme:

https://github.com/kennibc/moodle-theme_fordson/blob/master/config.php#L45-L52

which uses this layout which points to a mustache template:

https://github.com/kennibc/moodle-theme_fordson/blob/master/layout/frontpage.php#L64

which triggers this mustache which drastically changes the frontpage:

https://github.com/kennibc/moodle-theme_fordson/blob/master/templates/frontpage.mustache


Hope that helps,

Chris

Average of ratings: Useful (2)
In reply to Chris Kenniburg

Re: Changing the front page from a Boost's child theme

by Chris Kenniburg -
Picture of Particularly helpful Moodlers Picture of Plugin developers

However,

looking at your code you left out a ">" for lang menu as well as single quotes around langmenu.


Try this:  

$THEME->layouts = [ 'frontpage' => array( 'file' => 'columns2.php', 'regions' => array('side-pre'), 'defaultregion' => 'side-pre', 'options' => array('nonavbar' => true, 'langmenu' => false), ) ];


This will utilize the boost columns2 and not your own layout.  But if you are only removing the language menu that might be all you need.  

You can also just turn off displaying the language menu without having to touch the files.  Then it would not display and problem solved.

In reply to Chris Kenniburg

Re: Changing the front page from a Boost's child theme

by Alberto PM -

Oooops, you are right, I didn't write well the code, but I've tried (and I'm trying) as you say and doesn't work for me.

Even I've purged the cache but still displaying the langmenu in front page.

I didn't turn off displaying the language because I only want to remove it from the front page.

Maybe the best way is hidding it using SCSS... but I supose the 'langmenu' option is for that...


 

In reply to Chris Kenniburg

Re: Changing the front page from a Boost's child theme

by Alberto PM -

Hi Chris!

Sure your suggestions are gonna help me.

I'm going to take a look at your code and try what you tell me.


Thanks a lot for your reply!

In reply to Chris Kenniburg

Re: Changing the front page from a Boost's child theme

by Richard Oelmann -
Picture of Core developers Picture of Plugin developers Picture of Testers
Just to add to Chris' response - and may not be relevant to the specific changes you have identified, but adding for reference for other readers:
There are also new .mustache files in the various subfolders within the templates/ folder. Some of these are called from within the layout files, or other templates, some are called from functions in the classes/ folder (e.g. the login page now has a boost template, called from classes/output/core_renderer.php
For these, unless you are changing the template context there is no real need to copy the function to your child theme (it will be inherited), but you will need to copy the relevant .mustache file in its subdirectory structure so that you can edit it in your child theme.

Richard
Average of ratings: Useful (1)
In reply to Chris Kenniburg

Re: Changing the front page from a Boost's child theme

by Alberto PM -

Hi Chris and Richard!

Your suggestions help me a lot, thanks!

I've used the files Chris says and I think I got it.

And I think also I understand what you mean, Richard... As you told me with the login.mustache in this topic, it is possible to find .mustache templates in templates subfolders, isn't it?

Now I know if I don't need to change the template context I don't really need to work in a function in my child theme.

Thanks a lot!