Injecting HTML code in the footer with Moodle 4.0

Injecting HTML code in the footer with Moodle 4.0

by Nicolas Martignoni -
Number of replies: 7
Bildo de Core developers Bildo de Documentation writers Bildo de Particularly helpful Moodlers Bildo de Plugin developers Bildo de Testers Bildo de Translators

Hi devs!

To inject some info in the footer of all page, I've used the pluginname_standard_footer_html() function, which worked adequately in Moodle 3.x, but now in Moodle 4.0 this is output in the "footer" popover box, and do not reliably display on all window widths (which could be a bug, but I'm not sure, maybe I'm doing something wrong).

So I'd like to have a plugin injecting some html code just like the performance info, under the footer-container-popover area. Is there some way to inject something in this place?

For reference, the source code with the pluginname_standard_footer_html() function is here: https://github.com/moodlebox/moodle-tool_moodlebox/blob/master/lib.php

Average of ratings: -
In reply to Nicolas Martignoni

Re: Injecting HTML code in the footer with Moodle 4.0

by Nicolas Martignoni -
Bildo de Core developers Bildo de Documentation writers Bildo de Particularly helpful Moodlers Bildo de Plugin developers Bildo de Testers Bildo de Translators

Hi, seems my post went unnoticed, surely a bad timing.

Anyone? Did someone have issue with disappearing injected footer text when in the popover box (and not at the bottom of the page, eg. with smaller screens)?

In reply to Nicolas Martignoni

Re: Injecting HTML code in the footer with Moodle 4.0

by Renaat Debleu -
Bildo de Core developers Bildo de Particularly helpful Moodlers Bildo de Plugin developers
I think you will need a theme, there you can override the footer, standard_footer_html or debug_footer_html functions of the core_renderer to put extra data where you exactly want.
 
 
In reply to Renaat Debleu

Re: Injecting HTML code in the footer with Moodle 4.0

by Nicolas Martignoni -
Bildo de Core developers Bildo de Documentation writers Bildo de Particularly helpful Moodlers Bildo de Plugin developers Bildo de Testers Bildo de Translators

Indeed it is possible to override renderers in themes.

But this not what is needed: I need a way to inject a footer independently of the theme (because I don't know what theme is installed on the Moodle where the plugin get installed).

So the questions are: how to override a renderer from a plugin (not a theme)? If this is not possible, is there any way with a plugin to inject some code (like the performance info) just after the footer in Moodle 4.0 and later.

Any pointer would be greatly appreciated!

PS. It seems that this was already asked in 2014, with some other use cases, unfortunately without any answer: https://moodle.org/mod/forum/discuss.php?d=258975#p1125388

In reply to Nicolas Martignoni

Re: Injecting HTML code in the footer with Moodle 4.0

by Davo Smith -
Bildo de Core developers Bildo de Particularly helpful Moodlers Bildo de Peer reviewers Bildo de Plugin developers
No - you cannot override a renderer in any plugin other than a theme (mainly because, with competing overrides in different plugins, how would the system know which was the override to use - in terms of the theme, there is only ever one theme drawing the current page, so that always "wins" when deciding renderer overrides).

What you are looking for is the "before_footer" hook (for example, I've used this in my block_navbuttons plugin - https://github.com/davosmith/moodle-navbuttons/blob/c5b8a694d3f98875f5394ef5e2f91529273e83ca/lib.php#L62 ).

Anything returned by that function is output onto the page (assuming the site is running Moodle 3.10 or above; before then the hook still exists, but doesn't allow anything to be output onto the page, so all you can do is inject extra JavaScript onto the page, using the $PAGE->requires->... functions).
Average of ratings:Useful (1)
In reply to Nicolas Martignoni

Re: Injecting HTML code in the footer with Moodle 4.0

by Michael Milette -
Bildo de Core developers Bildo de Documentation writers Bildo de Particularly helpful Moodlers Bildo de Plugin developers Bildo de Testers Bildo de Translators
Hi Nicolas,

Take a look at the latest version of the Trema theme for Moodle 4.0 (May 4, 2022 release or later).

https://moodle.org/plugins/theme_trema

It is one of the first contributed Moodle Themes to fully embrace all of the Moodle 4.0 UI features while still maintaining some of the more traditional options that users expect to see - like a customizable footer.

Best regards,

Michael Milette
Average of ratings:Useful (1)
In reply to Nicolas Martignoni

Re: Injecting HTML code in the footer with Moodle 4.0

by Luis Britland -

Customising the header
  1. The administrator can add links, metatags, CSS or Java Script to the header section of your page via Site administration > Appearance > Additional HTML.
  2. You can specify HTML or CSS or JavaScript that you want added to every page without altering the Moodle code files.