0

so I'm hoping to achieve something relatively simple. I need to add an external css reference to a CDN and a local customjs file reference to the head of my template file.

Currently I am doing this directly which is a problem as changes are knocked out each time I Update. I'm looking for a way to dynamically include this changes on a permanent basis to prevent the issue from re-occurring but I'm not sure how to go about doing this.

I am using the hadron theme for this project on Joomla 3.9.2. Any help would be very much appreciated.

Just to add to the above, Ideally it would be great to achieve this without the use of another third-party extension. Wherever possible I like to keep external resources to a minimum.

  • 1
    You can use a plugin for that, like Load Custom CSS & JS plugin – n.h. Feb 14 at 15:05
  • I second the plugin proposed by n.h. I use it only for the admin area, though, because my base template already has custom.css and custom.js files that are not changed on updates. You should ask your template provider for that feature. – Jonathan Magoga Feb 14 at 15:08
  • Hi guys, ideally I don't want to add additional resources for this. I should be able to achieve the desired result via the Joomla include library surely? – Nick Feb 14 at 15:13
  • @Nick, the only other way apart from editing the core template file is using a plugin (which hooks into the core) be it your own or one developed by someone else. The result will be exactly the same and they're not heavy resources. – Lodder Feb 14 at 17:17
  • If you really do want something extremely basic, I can provide the code from my plugin which literally adds a few JS/CSS files. No parameters, no extra bloat – Lodder Feb 14 at 17:23
1

Good question and the "correct answer" as others have commented is that you probably need to use a plugin to do this properly.

The RocketTheme "Hadron" Gantry 4 template does allow a custom CSS file but does not provide any feature to include an external CSS or JS file.

You could avoid installing a plugin by adding the code via a custom HTML module. You will likely need to set the editor to "None" in your user settings or in Global Configuration while creating or editing the module so that the editor does not strip the code when saving.

Including <script> tags in the HTML body follows HTML 5 standards.

As per https://stackoverflow.com/a/16844668/1983389 and https://stackoverflow.com/a/50154225 <style> tags work fine in the body too and are now officially part of the HTML 5 standards.

1

Manic day hadn't had a chance to revisit this but I did manage to resolve the issue. The Hadron template actually has a placeholder for the header element called analytics. I was able to utilize the default custom html module to solve the problem.

Thanks all for replying. Failing the above solution I most likely would have just ended up building something myself. I'm always against adding more resources unless absolutely necessary.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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