API method to add moodle default help-button (tooltip)

API method to add moodle default help-button (tooltip)

by Florian Fassing -
Number of replies: 2

Hello,


is there an API way of adding a help-button to an arbitrary position like you do to forms with $mform->addHelpButton(...)? In my module there is a custom button getting rendered in the cm_info_view method. I'd love to have a default Moodle help-button next to it.


best regards

Average of ratings: -
In reply to Florian Fassing

Re: API method to add moodle default help-button (tooltip)

by Florian Fassing -

I found out, that it's probably done like this:


require_login($courseid);
$helpicon = new help_icon('langref', 'mymodulename');
echo $OUTPUT->render($helpicon);


It does work, but is it the correct way of doing this? Or is this deprecated?

In reply to Florian Fassing

Re: API method to add moodle default help-button (tooltip)

by David Mudrák -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators

That is valid. You can also use just

echo $OUTPUT->help_icon('stringid', 'plugintype_pluginname');

given that your plugin provides strings stringid and stringid_help. You can also use

echo $OUTPUT->heading_with_help(...);

All these are defined in the core_renderer class in the lib/outputrenderers.php file.

Average of ratings: Useful (1)