3

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();
3

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

  • 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. – Michael Yaeger Aug 2 '17 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 '17 at 16:18
  • I'm using the "Optimum" automatic settings group – Michael Yaeger Aug 2 '17 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 '17 at 18:21
  • OK, I'll give it a go and see... – Michael Yaeger Aug 2 '17 at 19:46

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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