0

where can i add a link to a custom css file in Joomla?

I have tried adding file in index.php but it is valid only for that template and if i load another template i lose the link.

I'm using Joomla 2.5.

cubitouch
  • 1,929
  • 15
  • 28
Marco Grieco
  • 229
  • 2
  • 6
  • 16
  • http://extensions.joomla.org/extensions/core-enhancements/coding-a-scripts-integration/head-code/25625 EDIT: Better answer: http://docs.joomla.org/J3.2:Adding_JavaScript_and_CSS_to_the_page – nobody Jan 30 '14 at 22:02
  • The link to a css file should be in the index.php of your template, why not just modify that one? To not "loose" the link in another template, you need to copy the css file you want, to the template you changed to. –  Jan 30 '14 at 22:04
  • Jeez, how many templates are you looking to load on your site? Keep separate CSS files for each template – Lodder Jan 31 '14 at 00:04
  • If your CSS file is related to any component then load inside that components view it will be available for all templates. Otherwise it should be template related and available for current template so you have to copy that to other template if necessary. – Jobin Jan 31 '14 at 02:43

1 Answers1

1

The right place for a site-wide css should be the template index.php file. But since you plan to use several templates, the only other meaningful option is to add it in a system plugin event, instead of spelling out the code you will need to use

$document->addStyleSheet($cssurl)

However it will be more effective if you just insert it into all your templates. Also please note that system page cache may not run the events on cache hits.

Riccardo Zorn
  • 5,590
  • 1
  • 20
  • 36