Joomla Less Library detailed Configuration

Configuration values and options described here. Make it easy and get Joomla-Developer-Bootstrap-Package

The followed described LessC Parameters listed in Conifuration order.

Safe starting

Write the Safe Joomla JLoader wrapper.

* Less with safe loading, without any errors
// insert the JProofLess::getInstance();
    // adding an Log message if it is an good choice to install the JProofLess
    JLog::add('JProofLess is missing: ' . __FILE__ . ' @see <a target="_blank" href=""><b>Wiki</b></a>',

    // Adding each time the regular already rendered css into the template if the LessCompiler not found
    JFactory::getDocument()->addStyleSheet($this->baseurl . '/templates/' . $this->template . '/css/template.css');

Getting Access to JProofLess $joomlaLess = JProofLess::getInstance()

$joomlaLess ->setLessVersion($version)

can be set on every position but before $joomlaLess->autoCompile()
possible $version

  • 4 default Version
  • 5 newest Version
  • Getting Joomla "JLess" is shipped by Joomla
    // or


Setting the Path in Joomla where the "Master" less file is located

$joomlaLess->setLessFile(JPATH_THEMES . '/' . $this->template . '/less/template.less')


Setting the output css file. The output css file can be stored everywhere (also in media-folder) . While using addStyle() the output css will be append to the Joomla Stylesheet

$joomlaLess->setCssFile(JPATH_THEMES . '/' . $this->template . '/css/template.css')
// or an other place
$joomlaLess->setCssFile('media/'.$this->template . '/css/another-name-if-you-want.css')

$joomlaLess->setCssMedia() optional for Responsive Layouts

Works, if

$joomlaLess->setAddStyle(); //enabled by default
is enabled

$joomlaLess->setCssMedia('only screen and (max-device-width:480px)');


Set the removal Flag for the cssFile before the Less-Compilation starts. Alternate you can also use the $joomlaLess->autoCompile(true)
This Part is usefull, for the case if you have an prebuild Processor that must not compile and this "Top-Build" must be compiled. So set the Remove Flag




From the Examples

$dependingLess = JProofLess::getInstance()
                   ->setLessFile(JPATH_THEMES . '/' . $this->template . '/less/imports.less')
                   ->setCssFile('media/' . $this->template . '/css/imports.css')

         /** Remove the Css file(if exists) before rendering    **/
         * The $dependingLess (Pre-build) Css file tells that we force the rendering only if needed

$joomlaLess->doRemoveCssFile($doRemove = true)

Simply remove directly an Css File. Settings and Compile Process can be continued after doRemoveCssFile().

JProofLess::getInstance()->setCssFile(JPATH_THEMES . '/' . $this->template . '/css/template.css')->doRemoveCssFile();


Setting a lot of variables from template backend configuration or somewhere else.
The Variables stack has one dimension. All added variables(also multidimension arrays) will be stacked into the one-dimension array
an Variable that already exist will be overridden
Variables will be stored before locally in JProofLess. While starting the autoCompile and the css file has to compile, the variables wie be pushed into the LessC (joomla|4|5)

Short Example

// Shorter with different Configuration Values from different Areas (template,component..what ever)

Longer Example

$variablesArray  = array('colorstyle' => 'red', 'testVar' => 'pink','anVar'=>'22px');
$variablesObject = (object) $variablesArray;

$multiDimensionsArray  = array($variablesArray, $variablesArray, "testVar" => 'green');
$multiDimensionsObject = (object) $multiDimensionsArray;

$joomlaLess = JProofLess::getInstance();

// as Array

// or as Object

// or as multiDimensionsArray

// or as multiDimensionsObject

$iniString = '
// or as INI formatted string

// or as JSON formatted string
$jsonString = '{"jsonVar":"yellow","jsonVar2":"pink"}';

{{thumbnail (jproofCast-JProofLess-export-CssFile-100-29_06_2015.png)}}