Techniques

by Alexander Limi — last modified Feb 20, 2010 08:27 PM
Methods to incorporate your own images, style sheets and JavaScript files into your theme.

Collective.xdv works by compiling the information from your theme.html template, your rules file and your Plone content into a brand new page.  Static files forming part of your theme, such as CSS, JavaScript and images, get pulled into the page after this compilation has taken place. As a result, your web server needs to know where to find these resources - it isn't automatically aware of the theme directory you set up to hold your template and rules.

In a production environment, you'll probably have Apache, Nginx or some other web server sitting in front of Plone and Zope, and, with the correct configuration, this will take care of making the static resources available to your compiled page. However, on a development computer - perhaps your own PC or laptop - you're probably more accustomed to just use Zope itself as the web server. In this case you've got several options for making your static resources available to your compiled page.

1. The Quick and Dirty

Your simplest option is to drop your resources into the Custom folder in portal_skins. Your Plone site will then find these resources through a simple relative link (such as href="test.css"). The disadvantage to this of course is that it's much harder to move these resources from site to site - and there's always the risk of losing them if you accidentally delete a site.

2. The Reflecto Method

Products.reflecto is a third-party add-on product which allows you to expose a section of your file system as if it were Plone content. In this case then, you can drop your static resources into a directory alongside your theme.html template, and work with them on the file-system. Once you've installed reflecto and set up a reflector content item to point at your static resources directory, your images and other files will be served just like any other piece of content in your Plone site.

3. The Slightly More Complicated

A more daunting option - particularly for the average web designer - is to set up a web server in front of Zope and Plone on your development instance and serve the static resources through these. In fact, it actually isn't as hard as you think to run a web server for development purposes. If you have a Mac running OS X.5, then the next page, Apache on your Mac, will take you through the basics. If you are running Windows, or a flavour of Linux, then many of the configuration details will be the same, but you will probably need to install Apache first.

4. The Hybrid Approach

This approach combines a traditional Theme Product Package with collective.xdv. It may well appeal to those designers schooled and seasoned in the old Plone 3 theming methods. Indeed, as an advanced technique, it combines the best of both worlds, in that Plone's registries can be used to cache resources or set conditions on when they are used. Other configuration details which might be required can also be embedded in this product. Denys Mishunov's Advanced XDV Theming tutorial will walk you through this technique.