[SOLVED] Compiling LESS from PHP with a child theme in $CFG->themedir

[SOLVED] Compiling LESS from PHP with a child theme in $CFG->themedir

by Gareth J Barnard -
Number of replies: 4
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

Hi all,

A bit of a dilemma!  Ok, what if you have a child theme of 'bootstrapbase' that has its CSS generated by LESS using the PHP Less compiler (https://docs.moodle.org/dev/Themes_overview#Compiling_LESS_on_the_fly) but it's installed in the folder set by $CFG->themedir?  Then the compilation fails because the relative folder as illustrated here: https://docs.moodle.org/dev/Themes_overview#Inheriting_from_a_parent no longer works.  So when a 'Purge all caches' or a 'theme cache' reset event because of a setting change then the error happens.  Would it be possible to inject the location of 'bootstrapbase' programatically with $CFG->dirroot etc. using '$THEME->extralesscallback' as stated here: https://docs.moodle.org/dev/Themes_overview#Programmatically_injecting_LESS ?

Thoughts?

Cheers,

Gareth

Average of ratings: -
In reply to Gareth J Barnard

Re: Compiling LESS from PHP with a child theme in $CFG->themedir

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

Solved using '$THEME->extralesscallback'.

In reply to Gareth J Barnard

Re: Compiling LESS from PHP with a child theme in $CFG->themedir

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

Sounds like a touch of Trial & Error

Glad you solved the problem

Cheers

In reply to Mary Evans

Re: Compiling LESS from PHP with a child theme in $CFG->themedir

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

Thanks Mary, just had a spark of inspiration.  It appears that the PHP LESS compiler is not really two-pass so order of import is important as against command line node.js / grunt.


Attachment 348650.jpg