User tests: Successful: Unsuccessful:
How to test:
edit template xml [isis.xml] file adding <field name="compile" type="compile" label="TPL_ISIS_COMPILE_LABEL" />
under a fieldset
create a folder fields and a file in that fodder named compile.php
and paste this code:
<?php
/**
* @package Joomla.Administrator
* @subpackage Templates.isis
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
jimport('joomla.filesystem.file');
class JFormFieldCompile extends JFormField
{
protected function getInput()
{
$app = JFactory::getApplication();
$template = $app->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 '<button onclick="window.location.href=\'' . $pageurl . '\'+\'&compileless=1\'" class="btn btn-primary" type="button">Compile Less</button>';
}
}
Visiting the admin -> templates -> isis [style] you should see the compile button. Press it an you will recompile the template.css
Labels |
Added:
?
|
Title |
|
Closing this so we don’t have multiple PR’s for one proposal
Status | Pending | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2014-09-18 12:36:14 |
Same comment here as in the other PR.
I'm not sure what the purpose is. It's already possible to use custom fields by providing the addfieldpath to the XML.
If I understand that correct, you just want to automate this so you don't have to define the path yourself?