? Success

User tests: Successful: Unsuccessful:

avatar dgt41
dgt41
17 Sep 2014

Introduces the same functionality as PR #4294

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('&amp;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 . '\'+\'&amp;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

avatar dgt41 dgt41 - open - 17 Sep 2014
avatar jissues-bot jissues-bot - change - 17 Sep 2014
Labels Added: ?
533d79b 17 Sep 2014 avatar dgt41 CS
avatar Bakual
Bakual - comment - 18 Sep 2014

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?

avatar dgt41
dgt41 - comment - 18 Sep 2014

@bakual Sorry for providing little info. What this and also the previous PR try to solve is remove the hardcoded code from xml's, so let's say is a sortcut and an easier way to introduce custom fields.

avatar dgt41 dgt41 - change - 18 Sep 2014
Title
Allow custom fields in templates installation file [xml]
Introduce predefined path in templates xml file for custom fields
avatar dgt41
dgt41 - comment - 18 Sep 2014

Closing this so we don’t have multiple PR’s for one proposal

avatar dgt41 dgt41 - close - 18 Sep 2014
avatar dgt41 dgt41 - close - 18 Sep 2014
avatar dgt41 dgt41 - change - 18 Sep 2014
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2014-09-18 12:36:14
avatar dgt41 dgt41 - head_ref_deleted - 19 Sep 2014

Add a Comment

Login with GitHub to post a comment