Adding an image from within a child theme on Moodle 3.11

Viewed 170

So, I'm new to Moodle and I'm creating a custom theme (child theme of Boost).

I'm a attempting to insert an image from the pix directory into the footer template - however I can't seem to get it to output any paths.

I've tried following the Moodle Docs - creating a directory mytheme/layout/footer.php and adding:

$templatecontext = [
  'imageone' => $OUTPUT->image_url('mylogo', 'theme'),
];

echo $OUTPUT->render_from_template('theme_mytheme/footer', $templatecontext);

then including the following in my mytheme/templates/theme_boost/footer.mustache:

<img src="{{{imageone}}}" alt="Please give your image alt text or set the role to presentation" width="50" height="50">

However, all I get is the alt text and blank src.

I assume I'm doing something silly - but I'm not familiar enough with the Moodle context/output/renderers etc. to troubleshoot much further than I already have. And the documentation is not the greatest!

Thanks for any pointers!

1 Answers

You are reading theme_mytheme/footer mustache and you have changed theme_boost/footer.mustache (overrided in your theme nonetheless). CHange

echo $OUTPUT->render_from_template('theme_mytheme/footer', $templatecontext);

to

echo $OUTPUT->render_from_template('theme_boost/footer', $templatecontext);

and then you can keep your example of mustache template

Related