GenericSetup and skinsΒΆ

Tags: plone

I had to figure out how genericsetup handles skins and layers. How to add layers? And more specifically, how to put them in the right order!

The basics

The basics are easy. (You should have some genericsetup machinery in place, for that you can always look at the tutorial). Just place a skins.xml in your product's profiles/default folder:

<?xml version="1.0"?>
<object name="portal_skins">
  <object name="locationaware"
          meta_type="Filesystem Directory View"
          directory="locationaware/skins/locationaware"/>
  <skin-path name="Plone Default">
    <layer name="locationaware"/>
  </skin-path>
  <skin-path name="Plone Tableless">
    <layer name="locationaware"/>
  </skin-path>
</object>

This registers locationaware's skin directory and adds the locationaware layer to the plone default and plone tableless skins.

Reordering skin layers

Now suppose you want to make sure your skin layers are in exactly the right order. Normally that means that you'd like to place one layer right at the top or before some other layer. Or behind.

<layer name="mylayer"/> adds that layer to the skin in the default location: all the way at the end. This is additive, so it doesn't mean you remove every other layer and just put this one in that skin path: it just adds this layer.

One important extra hint that's pretty crucial: if you specify a layer for inclusion in a skin path, it is first removed from that path if already present. So: whatever the original location, you're now free to insert it wherever you want.

You can control the placement of the layer with some extra attributes to that layer statement. An example that speak for itself:

<object name="portal_skins">
  <skin-path name="Plone Default">
    <layer name="mylayer"
           insert-before="kupu"/>
    <!-- '*' means all the way to the top/bottom. -->
    <layer name="custom"
           insert-before="*"/>
    <!-- insert-after="*" is actually the default. -->
    <layer name="myjunk"
           insert-after="*"/>
    <layer name="my_important_sitetheme"
           insert-after="custom"/>
  </skin-path>
</object>

So: it took me some time to grok the additive nature of genericsetup, but in the end it works quite nicely and intuitively.

 
vanrees.org logo

Reinout van Rees

My name is Reinout van Rees and I program in Python, I live in the Netherlands, I cycle recumbent bikes and I have a model railway.

Weblog feeds

Most of my website content is in my weblog. You can keep up to date by subscribing to the automatic feeds (for instance with Google reader):