Adding a fake block to a boost child theme Moodle 4.0

Adding a fake block to a boost child theme Moodle 4.0

by Tom Cripps -
Number of replies: 6

Hi lovely people, I'm wondering if I can get a bit of advice. I'm something of a novice at theming, but I often find some of the instruction examples in the Moodle docs to be helpful but also assume more knowledge than I currently have! I'd like to add a fake block to my Moodle 4.0 Boost child theme, and I'm trying to understand what to add to my theme's lib.php based off the instruction found here.

Adding the code as is, produces an error, and if I make it a fully formed function like so:

theme_fakeblock_get_html_for_settings(renderer_base $output, moodle_page $page) {

$bc = new block_contents();
$bc->title = 'fake title';
$bc->attributes['class'] = 'fakeblock';
$bc->content = 'fake content';
$page->blocks->add_fake_block($bc, 'side-pre');

}

– then add that to my theme's lib file then it produces no errors but doesn't add a fake block. I'm presumably missing something very obvious, but I can't work it out. Thanks for any assistance, I'm hoping it's something really simple!

Average of ratings: -
In reply to Tom Cripps

Re: Adding a fake block to a boost child theme Moodle 4.0

by Dominique Palumbo -
Picture of Particularly helpful Moodlers Picture of Plugin developers
Hi,

I try the same and I see also nothing with no error. I'm still looking for what I missed.

Dominique.
In reply to Tom Cripps

Re: Adding a fake block to a boost child theme Moodle 4.0

by Renaat Debleu -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers
Does your child theme implements a firstview_fakeblocks function in the core_renderer?
In reply to Renaat Debleu

Re: Adding a fake block to a boost child theme Moodle 4.0

by Dominique Palumbo -
Picture of Particularly helpful Moodlers Picture of Plugin developers
Hi,

in my case no. I don't implemented it.

I also get an error when I reset the theme cache.

Notice: Undefined property: theme_config::$haseditswitch in MoodleWindowsInstaller-latest-400\server\moodle\lib\adminlib.php on line 8868
(the line if ($PAGE->user_allowed_editing() && !$PAGE->theme->haseditswitch)  {)

Thank you.

Dominique.
In reply to Renaat Debleu

Re: Adding a fake block to a boost child theme Moodle 4.0

by Tom Cripps -
Hi Renaat,

I have not implemented that no, would you be able to let me know what to add to the core_renderer?

Apologies for the late response I've been away on holiday!
In reply to Tom Cripps

Re: Adding a fake block to a boost child theme Moodle 4.0

by Renaat Debleu -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers
I had issues with some themes until I implemented this code to the theme renderer and started debugging. Standard only the site-pre region is checked.