Using Plone's CSS and JavaScript Registries

by Alexander Limi — last modified Feb 20, 2010 08:50 PM
If you are making your static resources available through Plone you can use Plone's resource registries to deliver them. You may also use conditions to do this selectively.

It is sometimes useful to show some of Plone's CSS in the styled site. You can achieve this by using an xdv <append/> rule or similar to copy the CSS from Plone's generated <head/> into the theme. You can use the portal_css tool to turn off the style sheets you do not want.

However, if you also want the site to be usable in non-themed mode (e.g. on a separate URL), you may want to have a larger set of styles enabled when xdv is not used. To make this easier, you can use the following expressions as conditions in portal_css (and portal_javascripts, portal_kss, portal_actions, in page templates, and other places that use TAL expression syntax):

portal/@@xdv-check/enabled
Will return True if xdv is currently enabled. This will check both the 'enabled' flag in the Theme Transform settings, and the current domain. Use 'not: portal/@@xdv-check/enabled' to 'hide' a style sheet from the themed site.
portal/@@xdv-check/domain_enabled
Similar to the 'enabled' check, but only checks the domain, not the global 'enabled' flag in the control panel. This is useful if you want to apply the xdv transform outside Plone, but still need a way to control which domains get which styles.