Injecting HTML code in the footer with Moodle 4.0

Injecting HTML code in the footer with Moodle 4.0

Nosūtīja Nicolas Martignoni
Atbilžu skaits: 7
Core developers attēls Documentation writers attēls Particularly helpful Moodlers attēls Plugin developers attēls Testers attēls Translators attēls

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

Vidējais novērtējums: -
Atbildot uz Nicolas Martignoni

Re: Injecting HTML code in the footer with Moodle 4.0

Nosūtīja Nicolas Martignoni
Core developers attēls Documentation writers attēls Particularly helpful Moodlers attēls Plugin developers attēls Testers attēls Translators attēls

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)?

Atbildot uz Nicolas Martignoni

Re: Injecting HTML code in the footer with Moodle 4.0

Nosūtīja Renaat Debleu
Core developers attēls Particularly helpful Moodlers attēls Plugin developers attēls
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.
 
 
Atbildot uz Renaat Debleu

Re: Injecting HTML code in the footer with Moodle 4.0

Nosūtīja Nicolas Martignoni
Core developers attēls Documentation writers attēls Particularly helpful Moodlers attēls Plugin developers attēls Testers attēls Translators attēls

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

Atbildot uz Nicolas Martignoni

Re: Injecting HTML code in the footer with Moodle 4.0

Nosūtīja Davo Smith
Core developers attēls Particularly helpful Moodlers attēls Peer reviewers attēls Plugin developers attēls
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).
Atbildot uz Davo Smith

Re: Injecting HTML code in the footer with Moodle 4.0

Nosūtīja Nicolas Martignoni
Core developers attēls Documentation writers attēls Particularly helpful Moodlers attēls Plugin developers attēls Testers attēls Translators attēls
I found your code earlier, and adopted it. This is not as fine as I would, but it works at least.

Thanks a lot, Davo, you made my day!

PS. For any interested party, see here for my plugin modification: https://github.com/moodlebox/moodle-tool_moodlebox/commit/3a47ece97ee54c060fe6efff3269cf798ab35af2
Atbildot uz Nicolas Martignoni

Re: Injecting HTML code in the footer with Moodle 4.0

Nosūtīja Michael Milette
Core developers attēls Documentation writers attēls Particularly helpful Moodlers attēls Plugin developers attēls Testers attēls Translators attēls
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
Atbildot uz Nicolas Martignoni

Re: Injecting HTML code in the footer with Moodle 4.0

Nosūtīja 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.