Set different theme colours to usergroups within the same child theme of Boost

Set different theme colours to usergroups within the same child theme of Boost

by Franky Just -
Number of replies: 4

With the local profiletheme plugin it's possible to link a specific theme to a user with an extra profile field on signing up, based on rules that an admin can create. I've tested this plugin (M3.6), and this works fine. I was wondering if it would be possible to use the same sort of functionality, but then within a child theme of Boost. 

E.g. to link specific scss-preset files to specific usergroups with an extra profile field on signing up. Extra themes means many extra files. When you only want to define a set of different colors for specific usergroups, it would be more efficient to look for a solution within the same theme. Would this be possible at all, if yes, what would be a good starting point?

Average of ratings: Useful (1)
In reply to Franky Just

Re: Set different theme colours to usergroups within the same child theme of Boost

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

Hi, 

This is just a guess, but I think it is possible providing there is a usergroup body class in the page source.

if there is then all you need are a set of styles using SCSS markup added to the Raw Initial SCSS in your child theme in groups using the user group class, which, if done correctly, should style your usergroups accordingly.

Hope this helps,

Mary

In reply to Franky Just

Re: Set different theme colours to usergroups within the same child theme of Boost

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

I think you misunderstand the purpose of SCSS.  SCSS is a pre-processed language that generates the CSS which is then cached.  Therefore you can't link to specific 'presets'.  Rather that they would all need to be wrapped up with a 'preset' prefixing class (so that the CSS contains all of the presets) that the PHP then alters the markup on.  Just like Essential implements the alternative colour schemes.

In reply to Franky Just

Re: Set different theme colours to usergroups within the same child theme of Boost

by Bas Brands -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers

Hi Franky,

Technically it is possible but it will require some Moodle core changes. Gareth already mentioned the core caching mechanism that sends just one cached css file to the end user per theme.

Core can be changed to create multiple caches per theme, one for each set of sass variables. I have been experimenting with and so far the results seem promising, I hope to be able to share the solution some time soon.

Average of ratings: Useful (1)
In reply to Bas Brands

Re: Set different theme colours to usergroups within the same child theme of Boost

by Franky Just -

Hi all,

The input from Bas sounds good! I seems that this comes as closest to my wishes.

Nevertheless, I will look also into the other two suggestions from Mary and Gareth.

Thx all for your input so far.

Franky