3

Someone at stackoverflow recommend I ask the question here, apologies if this is considered cross-posting...

OVERVIEW

I am developing a set of custom templates and a set of custom modules.

The templates will be different, but their parameters (defined in templateDetails.xml) will remain identical.

I want the default (site) template to send its parameter values to an intermediary file, variables.css.php

variables.css.php currently resides in ../media/cms/css (Not sure if it needs to be someplace else)

The purpose for this is so that even if I change between templates, the modules can still find the parameter values in the same location.

Again, the parameter values may change, but the parameters themselves (color1, color2, etc) will not.

I have included a diagram which will hopefully help illustrate: enter image description here

I want the module's backend to get the parameter values, so an administrator can see what color they are picking when they are configuring the modules.

That is, a button’s background color in the module’s config page will match the color defined in templateDetails.xml.

I have built a working template.

I have built variables.css.php:

<?php
define( '_JEXEC', 1 );
define( '_VALID_MOS', 1 );
define( 'JPATH_BASE', realpath(dirname(__FILE__).'/../../..' ));
define( 'DS', DIRECTORY_SEPARATOR );
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );

$app = JFactory::getApplication('site');
// $app->initialise();
$defaultTemplate = $app->getTemplate(true);
$params = $defaultTemplate->params;

header("Content-Type:text/css; charset=UTF-8");
header("Cache-Control:must-revalidate");
?>

.bg01 {text-shadow: 0px 0px 4px #000; color: #fff; background-color:<?php echo $params->get('color01'); ?>; }
.bg02 {text-shadow: 0px 0px 4px #000; color: #fff; background-color:<?php echo $params->get('color02'); ?>; }
.bg03 {text-shadow: 0px 0px 4px #000; color: #fff; background-color:<?php echo $params->get('color03'); ?>; }
.bg04 {text-shadow: 0px 0px 4px #000; color: #fff; background-color:<?php echo $params->get('color04'); ?>; }
.bg05 {text-shadow: 0px 0px 4px #000; color: #fff; background-color:<?php echo $params->get('color05'); ?>; }
.bg06 {text-shadow: 0px 0px 4px #000; color: #fff; background-color:<?php echo $params->get('color06'); ?>; }
.bg07 {text-shadow: 0px 0px 4px #000; color: #fff; background-color:<?php echo $params->get('color07'); ?>; }
.bg08 {text-shadow: 0px 0px 4px #000; color: #fff; background-color:<?php echo $params->get('color08'); ?>; }
.bg09 {text-shadow: 0px 0px 4px #000; color: #fff; background-color:<?php echo $params->get('color09'); ?>; }
.bg10 {text-shadow: 0px 0px 4px #000; color: #fff; background-color:<?php echo $params->get('color10'); ?>; }
.bg11 {text-shadow: 0px 0px 4px #000; color: #fff; background-color:<?php echo $params->get('color11'); ?>; }
.bg12 {text-shadow: 0px 0px 4px #000; color: #fff; background-color:<?php echo $params->get('color12'); ?>; }
.bg13 {text-shadow: 0px 0px 4px #000; color: #fff; background-color:<?php echo $params->get('color13'); ?>; }
.bg14 {text-shadow: 0px 0px 4px #000; color: #fff; background-color:<?php echo $params->get('color14'); ?>; }
.bg15 {text-shadow: 0px 0px 4px #000; color: #fff; background-color:<?php echo $params->get('color15'); ?>; }
.bg16 {text-shadow: 0px 0px 4px #000; color: #fff; background-color:<?php echo $params->get('color16'); ?>; }

And I have built a working module. The module loads variables.css.php using this trick

THE PROBLEM

The problem is when I go into the module’s backend, the config buttons look like this enter image description here

When they should look like this enter image description here

When I use Chrome to inspect the module’s config page I find the following:

.bg01 {
    text-shadow: 0px 0px 4px #000;
    color: #fff;
    background-color: ;
}

I know that the module is loading variables.css.php -- because it is showing the text-shadow and color values. However background-color is blank.

Which means the parameter values in variables.css.php are empty.

This is where I need help.

I assume the code (above the css) in variables.css.php is incorrect.

Any help is greatly appreciated!

2
  • 1
    The code looks right to get your template params. Do the color values exist in the templateDetails.xml?
    – James
    Commented Nov 19, 2020 at 21:33
  • 1
    I hear you saying "in the module's backend". Is this a site versus administrator issue? joomla.stackexchange.com/q/1129/12352 , stackoverflow.com/a/14980716/2943403 Are you seeing any errors in your error log? Do you have your error reporting turned on/up? Please take our tour and consider introducing yourself in your profile. Commented Nov 19, 2020 at 22:21

1 Answer 1

0

After much frustration I finally traced the problem to a typo in the templateDetails.xml. Once I fixed that, the code/method I outlined above worked, and the button styling in the module's backend appeared in all its colorful glory.

1
  • Please edit your answer to remove the thank yous and explain in better detail how you fixed your rookie mistake. Commented Nov 24, 2020 at 12:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.