General developer forum

Adding text to core page via local plugin

 
Picture of H W
Adding text to core page via local plugin
 
Hello Moodle Community Members.

I've been trying to search for an answer but didn't found one.

I'd like to add text to Reset Course page (course/reset.php) via local plugin. Is this possible?  Are there hooks or something else available that allows adding HTML to specific Moodle core page? Even warning could do the trick if it is possible.

 
Average of ratings: -
Picture of Andreas Grabs
Re: Adding text to core page via local plugin
Core developersParticularly helpful MoodlersPlugin developersTranslators

Hi,

maybe this could be usefull for you.

There is a config setting "$CFG->customscripts" to override core scripts without modifying them. This works only if the script you want to override includes the "config.php". All other scripts do not make usage of this.

Example:

Create in your moodle directory a subfolder "_custom" (this name is not mandatory). In this folder you can create the structure of the file you want to override. In your case it would be "course/reset.php".

The relative path in your moodle should look like this:

_custom/course/reset.php

Now you have to edit the file "_custom/course/reset.php":

<?php
// Put your injections in here.
// The rest of this file should be empty!

Now you have to add the configuration to your "config.php". This must be done before the setup inclusion.

Example config.php:
<?php
...
$CFG->customscripts = dirname(__FILE__).'/_custom';
...
require_once(dirname(__FILE__) . '/lib/setup.php'); // Do not edit


The result is that each time while course/reset.php is loaded your injections are loaded first.

I hope it is understandable. Sometimes my english is a bit weird.

Best regards
Andreas

 
Average of ratings: Useful (1)
Davo
Re: Adding text to core page via local plugin
Core developersParticularly helpful MoodlersPlugin developers
One possible simpler solution might be to look at the text on the page and edit one of the language strings to add the warning you want ( https://docs.moodle.org/en/Language_customisation ).

I've not looked to see if there are any suitable language strings on that page, but I would have thought there should be.

Note you should also be able to add HTML tags to the language strings in order to make the warning stand out (I've never actually tried to do that via the UI, but I've certainly put HTML in language strings in PHP files before).


 
Average of ratings: -