Generate CSS or JS dynamically for a Joomla module

302 views Asked by At

I am writing a Joomla module that includes a custom CSS stylesheet:

$document->addStyleSheet("modules/mod_custommenu/css/custommenu.css");

Now, this module needs to allow for customization of several CSS properties. I could include CSS inline in the module template, but I'd rather reference a separate file. I would like to:

  1. Reference a separate CSS object (via URL)
  2. Generate that CSS file using Joomla templates, like:

.custommenu_<?php echo $module->id; ?> .menutitle { color: <?php echo $params->get('titlecolor'); ?>; }

  1. If possible, cache the rendered CSS file so Joomla doesn't need to generate it everytime it is accessed.

How can I do this? Or what is the correct approach for generating ad-hoc module CSS files?

0

There are 0 answers