joomla/joomla-cms — pull request #4295 by dgt41 (2014-09-17 22:03:12+00:00)
Title: Allow custom fields in templates installation file [xml]

#### Introduces the same functionality as PR #4294

How to test:
edit template xml [isis.xml] file adding
`````` under a fieldset
create a folder fields and a file in that fodder named ```compile.php```
and paste this code:
```
getTemplate(true);
$params = $template->params;
$jinput = $app->input;
$compile = 0;
$compile = $jinput->get('compileless');
$currentpath = dirname(realpath(__DIR__));
$pageurl = str_replace('&compileless=1', '', JURI::getInstance());

if ($compile)
{
// Load the RAD layer to use its LESS compiler
if (!defined('FOF_INCLUDED'))
{
require_once JPATH_LIBRARIES . '/fof/include.php';
}

$less = new FOFLess;
$less->setFormatter(new FOFLessFormatterJoomla);

//update variables.less
$less->setVariables(array(
"templateColor" => $params->get('templateColor'),
"headerBackground" => $params->get('headerColor'),
"sidebarColor" => $params->get('sidebarColor')
));

try
{
$less->compileFile($currentpath . '/less/template.less', $currentpath . '/css/template.css');
} catch (Exception $e)
{
$app->enqueueMessage($e->getMessage(), 'error');
}
}

return 'Compile Less';
}

}
```
Visiting the admin -> templates -> isis [style] you should see the compile button. Press it an you will recompile the template.css