Projekt

Allgemein

Profil

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
**/
if(JLoader::import('jproofless.jproofless')){
// insert the JProofLess::getInstance();
}
else{
    // 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="http://wiki.jproof.de/projects/joomla-library-jproof-less/wiki"><b>Wiki</b></a>',
          JLog::NOTICE);

    // 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
     $joomlaLess->setLessVersion(4)
    
  • 5 newest Version
     $joomlaLess->setLessVersion(5)
    
  • Getting Joomla "JLess" is shipped by Joomla
     $joomlaLess->setLessVersion('joomla');
    // or
     $joomlaLess->setLessVersion('3.9')
    

$joomlaLess->setLessFile('')

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

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

$joomlaLess->setCssFile('')

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)');

$joomlaLess->setRemoveCssFileFlag(true)

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

$joomlaLess->setRemoveCssFileFlag(true);

Alternative

$joomlaLess->autoCompile(true)

From the Examples

$dependingLess = JProofLess::getInstance()
                   ->setLessVersion('joomla')
                   ->setLessFile(JPATH_THEMES . '/' . $this->template . '/less/imports.less')
                   ->setCssFile('media/' . $this->template . '/css/imports.css')
                   ->setAddStyle(false)
                   ->setCompression('compressed')
                   ->autoCompile();

    JProofLess::getInstance()
             ......
         /** Remove the Css file(if exists) before rendering    **/
          ->setRemoveCssFileFlag(true)
          .....
          ->setExtraContent($dependingLess->getCssFileContent())
        .....
              /**
         * The $dependingLess (Pre-build) Css file tells that we force the rendering only if needed
         **/
          ->autoCompile($dependingLess->isHasParsed());

$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();

$joomlaLess->setVariables(array|stdClass)

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)
$joomlaLess->setVariables($fromAnConfig)->setVariables($fromAnOtherConfig)

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
$joomlaLess->setVariables($variablesArray);

// or as Object
$joomlaLess->setVariables($variablesObject);

// or as multiDimensionsArray
$joomlaLess->setVariables($multiDimensionsArray);

// or as multiDimensionsObject
$joomlaLess->setVariables($multiDimensionsObject);

$iniString = '
myIniVar=red
myOtherIniVar=green
';
// or as INI formatted string
$joomlaLess->setVariables($iniString);

// or as JSON formatted string
$joomlaLess->setVariables($jsonString);
$jsonString = '{"jsonVar":"yellow","jsonVar2":"pink"}';

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