Practical: Adding a Style Sheet to the Registry in your own Theme Product
Create your Style Sheet
- Create a normal CSS file [mytheme.css] using your favourite CSS editor.
- You now have two options:
- The simplest place to put your style sheet is in the skins directory of your theme product. Paster will have created a styles directory for you (skins/plonetheme_mytheme_styles).
- Paster will also have created a stylesheets directory for you in the browser directory of your theme product and will have registered this as a resource in the configure.zcml file. You can, if you like, put your style sheet in that directory instead.
Write your Generic Setup File
The relevant files for the configuration of your registries are profiles/default/cssregistry.xml and profiles/default/jsregistry.xml. Paster should have created these for you, but if they aren't there, just make them yourself.
An entry for a style sheet in the skins directory of your theme product, will look like this:
<?xml version="1.0"?> <object name="portal_css" meta_type="Stylesheets Registry"> <stylesheet title="" cacheable="True" compression="safe" cookable="True" enabled="1" expression="" id="mytheme.css" media="screen" rel="stylesheet" rendering="import"/> </object>
Note that the parameters are just the same as the through-the-web form. You need only give the ID of the style sheet; Plone will find it as it is part of the skin.
An entry for a style sheet in the browser directory of your theme product will look like this:
<?xml version="1.0"?> <object name="portal_css"> <stylesheet title="" id="++resource++plonetheme.mytheme.stylesheets/mytheme.css" media="screen" rel="stylesheet" rendering="import" cacheable="True" compression="safe" cookable="True" enabled="1" expression=""/> </object>
Note the special ++resource++plonetheme.mytheme.stylesheets syntax to refer to the directory registered as a resource in browser/configure.zcml
Once written, you can reimport the cssregistry.xml file using the portal_setup tool in the ZMI to make this change take effect. Make sure you choose the correct profile (your theme product) before importing the CSS step. Re-installing your theme product will also work, though you should be careful to guard against GenericSetup clashes. It's safer to import the individual step if your theme has been installed previously.
Plone Version 3.3 Onwards
In Plone 3.3 onwards you can also tell the CSS Registry to put conditional comments around your stylesheet:
<stylesheet title="" cacheable="False" compression="none" cookable="False" rel="stylesheet" expression="" id="IEFixes.css" media="all" enabled="1" rendering="import" conditionalcomment="IE" />
You can also specify an external resource:
<javascript cacheable="False" compression="none" cookable="False" enabled="True" expression="" id="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js" inline="False" insert-before="jquery-integration.js" />
If you are using SSL and specifying an external resource, you may find it necessary to specify both an http and an ssl entry in the registry. You can use the expression parameter to decide which one will be used:
<javascript cacheable="False" compression="none" cookable="False"
enabled="True" expression="python:request.get('ACTUAL_URL','').startswith('https://')"
id="https://jqueryjs.googlecode.com/files/jquery-1.2.6.min.js"
inline="False" insert-before="jquery-integration.js" />
<javascript cacheable="False" compression="none" cookable="False"
enabled="True" expression="python:request.get('ACTUAL_URL','').startswith('http://')"
id="http://jqueryjs.googlecode.com/files/jquery-1.2.6.min.js"
inline="False" insert-before="jquery-integration.js" />

Author: