Where to put CSS files
From Joomla! Documentation
Revision as of 17:31, 9 October 2008 by UweDuesing (talk | contribs)
This article is a small, well-defined item that could be completed by someone with a reasonable knowledge of the subject matter and a modest time commitment. If you would like to try writing this article you're welcome to do so.
The subject may be self-evident, but if not then further details should be available on the discussion page. Please add {{inuse}} at the top of this page while editing. For other small, well-defined tasks, please look in the Cookie jar. ---Thank you. This article was last edited by UweDuesing (talk| contribs) 15 years ago. (Purge) |
Where to include your CSS files depends on what you would like to achieve with them.
1. Template The CSS within the template folder is meant to be globally valid for the whole site. That means the CSS is not only authored for one specific component or module within Joomla! but for the whole installation.
Creating a new template or modifying an existing one -> This is the right way to do it.
2. Component or Module
Creating a new component / module you might want to keep the CSS files with the component/module so that everything displays nicely no matter where it is going to be installed later on.
One place for the include statement can be the main component file of your component/module folder. Creating a CSS folder within your component/module folder structure and using the following code works fine for components and modules:
$document = &JFactory::getDocument(); $document->addStyleSheet('components'.DS.'com_xyz'.DS.'css'.DS.'xyz.css');