Open mczaja opened 1 year ago
Hi @mczaja,
thanks for reporting this issue. We do indeed only support boost as a theme, and usually all themes that are based on Boost. Let me check with the developers how much effort it would be to support different icon styles.
Feel free to provide a pull request if you have the resources to do so and we'll review it.
I am surprised that there still exist themes that are not based on boost, is that a theme you built yourself or a third party one? I am curious to see it (if possible).
All the best Stefan
Yes, it is the standalone theme. Built from scratch. (https://rosea.io/space2-theme/)
Oh, that explains why your name sounded familiar @mczaja — I actually like space it a lot, wasn't aware that it's not boost based. Good job!
I don't know if it's the best approach, but I'm using the code below with no problems in Boost among other premium themes.
// Preset Icon.
$icon = $OUTPUT->image_url('i/edit', 'core')->out();
$mform->addElement('html', '<img src="'.$icon.'">');
$mform->addElement('text', 'boxicon', get_string('boxicon', 'pulse'));
$mform->setType('boxicon', PARAM_TEXT);
$mform->hideIf('boxicon', 'displaymode', 'neq', 1);
$this->standard_coursemodule_elements();
// Form submit and cancel buttons.
$this->add_action_buttons(true, false, null);
This is the fix that is needed to not assume the theme is configured with icons:
diff --git a/mod/pulse/mod_form.php b/mod/pulse/mod_form.php
index 08da3742de3..8e39dd9561c 100644
--- a/mod/pulse/mod_form.php
+++ b/mod/pulse/mod_form.php
@@ -143,12 +143,16 @@ class mod_pulse_mod_form extends moodleform_mod {
// Preset Icon.
$theme = \theme_config::load($PAGE->theme->name);
- $faiconsystem = \core\output\icon_system_fontawesome::instance($theme->get_icon_system());
- $iconlist = $faiconsystem->get_core_icon_map();
- array_unshift($iconlist, '');
- $mform->addElement('autocomplete', 'boxicon', get_string('boxicon', 'pulse'), $iconlist);
- $mform->setType('boxicon', PARAM_TEXT);
- $mform->hideIf('boxicon', 'displaymode', 'neq', 1);
+ if (!empty($theme->iconsystem)) {
+ $faiconsystem = \core\output\icon_system_fontawesome::instance($theme->get_icon_system());
+ $iconlist = $faiconsystem->get_core_icon_map();
+ array_unshift($iconlist, '');
+ $mform->addElement('autocomplete', 'boxicon', get_string('boxicon', 'pulse'), $iconlist);
+ $mform->setType('boxicon', PARAM_TEXT);
+ $mform->hideIf('boxicon', 'displaymode', 'neq', 1);
+ } else {
+ $mform->addElement('hidden', 'boxicon', get_string('boxicon', 'pulse'));
+ }
$this->standard_coursemodule_elements();
// Form submit and cancek buttons.
Dears.
I'm testing Pulse v. 1.3 build 2023051801 with latest version of Space Theme in Moodle 4.1.1 and got the above mentioned error (Coding error detected, it must..)
It seems the problem has been resolved but I don't understand how me, an average Moodle user can resolve it: Is there a new build of Pulse free with the error resolved? or Could anybody provide some brief Instructions on what file should I edit with the code described above?
Thanks in advance. Fabian
Coding error detected, it must be fixed by a programmer: Invalid icon system requested '\core\output\icon_system_standard' line 92 of /lib/classes/output/icon_system.php: coding_exception thrown line 146 of /mod/pulse/mod_form.php: call to core\output\icon_system::instance() line 214 of /lib/formslib.php: call to mod_pulse_mod_form->definition() line 131 of /course/moodleform_mod.php: call to moodleform->__construct() line 154 of /course/modedit.php: call to moodleform_mod->__construct()
Would it be possible to incorporate an alternative solution for themes that don't based on the Boost and FontAwesome icon system?
Moodle allows using 3 different icon styles:
Thanks, Marcin