2

JCH outputs the combined and compressed CSS file as:

/media/plg_jchoptimize/assets/gz/1/0/21258391ff538dceaca26d18cb55cb1b.css

Since this is a randomly generated link every time JCH refreshes the file, is there a way to retrieve the URL programmatically?

I am thinking something like this URL would allow me to reference the CSS file from outside the Joomla! environment (this is just for reference as I realize it would never work as written):

/index.php?option=plg_jchoptimize&view=css

The CSS reference is redirected to a PHP file:

/media/plg_jchoptimize/assets/jscss.php

The contents of that file are:

require_once dirname(dirname(dirname(dirname(__FILE__)))) . '/plugins/system/jch_optimize/bootstrap.php';

loadJchOptimizeClass('JchOptimizeOutput');

JchOptimizeOutput::getCombinedFile();

1 Answer 1

2

Good question. Looking at a different approach, you could use PHP to get all the CSS files in the given directory and then import them.

Something like so:

$dir = 'media/plg_jchoptimize/assets/gz/1/0/*.css';

foreach (glob($dir) as $css)
{
    echo "<link rel='stylesheet' href='$css'>\n";
}

This is of course assuming that the website that's outside of your Joomla environment is on the same server

7
  • Great thinking outside the box! Unfortunately, these are not actual files that are stored on the server--they're just redirects to a file generated by PHP. However, that did get me thinking about calling the PHP directly. I have updated the question with info on that. Aug 2, 2017 at 16:01
  • @MichaelYaeger what do you have Combined Files Delivery set to in the plugin options? Just so I can try and replicate this.
    – Lodder
    Aug 2, 2017 at 16:18
  • I'm using the "Optimum" automatic settings group Aug 2, 2017 at 17:05
  • Spent a while looking through the plugin code and there are so many functions in so many files. Unfortunately I wasn't able to figure it out, but I believe that if you set Combined Files Delivery, you'll be able to use the code (changing the path of course) in my answer
    – Lodder
    Aug 2, 2017 at 18:21
  • OK, I'll give it a go and see... Aug 2, 2017 at 19:46

Your Answer

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

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