Easy css and javascript registry usage

by Reinout van Rees last modified Dec 30, 2008 05:48 PM

ArchGenXML has an easy way to register your stylesheets and javascripts with the registry.

To use the css and javascript registry, you just need a tiny bit of configuration in your config file and ArchGenXML handles the rest (from version 1.4.0 onward).

Code example for in the AppConfig.py :

 # This adds two javascripts to the global registry
 JAVASCRIPTS = [{'id': 'hideShow.js'},
                {'id': 'tabsDropDown.js'}
                ]
 # This adds one global stylesheet
 STYLESHEETS = [{'id': 'internetlayout.css'}]
 # This version adds two stylesheets that are only  used when a
 # specific content type is used. You can mix the two, of course.
 STYLESHEETS = [{'id': 'newsitem.css',
                 'expression':  'python:object.getTypeInfo().getId() == "Newsitem"'},
                {'id': 'pressrelease.css',
                 'expression': 'python:object.getTypeInfo().getId() == "Pressrelease"'}]

That's it! Especially easy for just plugging in that one stylesheet you've defined. One line of code and you're done!

(Tip lifted from here after gentle prodding from Limi).