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.

4
  • extensions.joomla.org/extensions/core-enhancements/… EDIT: Better answer: docs.joomla.org/J3.2:Adding_JavaScript_and_CSS_to_the_page Commented Jan 30, 2014 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. Commented Jan 30, 2014 at 22:04
  • Jeez, how many templates are you looking to load on your site? Keep separate CSS files for each template Commented Jan 31, 2014 at 0: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. Commented Jan 31, 2014 at 2:43

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.