Posts made by David Scotson

I don't think it works by default in normal themes because it'll strip out HTML, and I think the same is true in Essential (though Julian may well have added a tweak to make it work while I wasn't paying attention). It's relatively easy to change the custom menu to take an icon name and add it to the menu items though if he hasn't done so already.

There's some code that does it here, by hijacking the "title" attribute (which I think is somewhat useless these days) to smuggle icons through:

https://github.com/ds125v/moodle-theme_bootstrap_renderers/blob/master/renderers/core_renderer.php#L599-L607
The icon font needs to be one of the font options set via CSS. I think you can just set the font icon as the first choice and any character it doesn't have will be picked up by the next font in the list, so you're effectively using two different fonts for the different types of characters.

However, if that text is then re-used elsewhere (e.g. sent out as an email) then you no longer have control over the fonts. So you might want to be careful about adding icons in this way. (The other thing to watch out for is installing the icon font locally, which may mean you see icons where normal users wouldn't).

I'd stick to either using the HTML method (where it's allowed), or Julian's CSS method for more permanent parts of the interface. Places where Moodle strips the HTML are usually re-used in various ways within the interface, so you might get unexpected effects if you're adding strange characters.

Julian's method is necessary for adding things to the interface of Moodle, but for adding to the content the way I described is easier. If you're getting a box then that points towards problems with the font loading which you might want to look into.

Adding

<i class="icon-pencil"></i>

certainly works for me in the Essential theme, (though sometimes there are areas in Moodle where any kind of HTML just gets stripped out e.g. Block titles).

Average of ratings: Useful (1)