Difference between revisions of "Scripts Class"
|Line 40:||Line 40:|
Revision as of 15:26, 1 April 2011
Setting a CSS File
To set a CSS file for your plugin you would point the Scripts class to the file like so:
global $_SCRIPTS; $_SCRIPTS->setCSSFile('polls', '/polls/style.css');
This tells the Scripts class to include the style sheet called polls. It is also telling the class that you plan to always include this CSS file. The reason you want to tell Geeklog that you plan to always include this CSS file is that it will then be marked for caching and compressing (future feature). If you plan to only include this CSS file on pages that the plugin displays you may want to include an extra parameter in the call to the class:
global $_SCRIPTS; $_SCRIPTS->setCSSFile('polls', '/polls/style.css', false);
As stated before this needs to be done before you run the function COM_SiteHeader or in your plugins plugin_getheadercode_xxxx function. If your plugin has a block or uses Autotags that need the CSS file then you should always make sure it is included since Geeklog has no way of knowing if a block or Autotag will be displayed before the header is written.
This will automatically wrap the code in the html script tag. If you do not want this to happen just remove the "true" from the function call.