Font awesome in custom menu

Font awesome in custom menu

از Eli Fadida در
Number of replies: 7

Hello, Im using Moodle version 3.6.1 with adaptable theme.


Is there a way to add font awesome to the custom menu items without tweaking the renderers.php file ? 


I need a simple menu like this one, but with the icons before the added items (documentation etc..):



currently the menu item configurations looks like: 

menu


Thanks


میانگین امتیازات: -
In reply to Eli Fadida

Re: Font awesome in custom menu

از Jean-Roch Meurisse در
تصویر Core developers تصویر Plugin developers تصویر Testers

Hi Eli,

Quite tweaky, but you can try to add some scss rules (Example below for boost-based themes)

nav.navbar .navbar-nav .nav-item a:before {
font-family: FontAwesome;

}
and for each one of your custom nodes add

nav.navbar .navbar-nav .nav-item {
&:nth-of-type(X) a:before {
content: "\f047";
}

}
where X is the index of your custom node in the navbar and "\f047" is the font-awesome code of an icon (here fa-arrows)

Hope it helps

In reply to Eli Fadida

Re: Font awesome in custom menu

از Jon Bolton در
تصویر Testers

Reasonably easy using CSS and if you want different icons for different links, you can see a working example at https://practicelearning.info

Here’s an extract of the CSS from that site:

.dropdown-menu>li>a[title="ScOPTbox Resources"]:before{content:"\f15b"; font-family: FontAwesome; width: 1.2em; display: inline-block; text-align: center; margin-right: 0.5em;}
.dropdown-menu>li>a[title="Reading Reviews"]:before{content:"\f02d"; font-family: FontAwesome; width: 1.2em; display: inline-block; text-align: center; margin-right: 0.5em;}
.dropdown-menu>li>a[title="Links"]:before{content:"\f0c1"; font-family: FontAwesome;  width: 1.2em; display: inline-block; text-align: center; margin-right: 0.5em;}

Actually, looking over that now, this CSS is actually quite messy. You could probably define the font-family, width, display, text-align and margin for the whole navbar and then just define the content for each link. But this is old and it works and I don't have to time to redo the whole site at the moment 😕

In reply to Jon Bolton

Re: Font awesome in custom menu

از Gareth J Barnard در
تصویر Core developers تصویر Particularly helpful Moodlers تصویر Plugin developers

I'm sure I had some custom code once in a theme whereby the custom menu would do this for you.  Just can't remember where.

In reply to Gareth J Barnard

Re: Font awesome in custom menu

از Mary Evans در

Hi Gareth.

You used to be able to add HTML in the text you type in URL part of the Theme settings Custom Menu.

Is that what you might be thinking of?

Just a thought...

Cheers

M

In reply to Mary Evans

Re: Font awesome in custom menu

از Gareth J Barnard در
تصویر Core developers تصویر Particularly helpful Moodlers تصویر Plugin developers

Hi Mary,

Sort of.  But I'm sure once I wrote some regex code to pull the string apart and see if there was a FontAwesome icon and if so use that!  Might have been in Shoehorn!

G

In reply to Gareth J Barnard

Re: Font awesome in custom menu

از Mary Evans در

Mutant Banjo?