Edit Theme Switcher for plone.app.theming

How to switch off plone.app.theming for editing.

Mirror TrackNow with plone.app.theming we are in the lucky situation to deliver really any design with Plone.

But there are also designers out in the wild creating designs not compatible with Plones edit-mode.

So its sometimes easier to edit in the classic Plone UI (Sunburst Theme) using a different web address for editing.

And here is how to do it:

  1. Consider to configure two adresses http://edit.domain.tld and http://www.domain.tld 
  2. Add a subscriber to zope.app.publication.interfaces.IBeforeTraverseEvent to configure.zcml
    <configure ...
        for="* zope.app.publication.interfaces.IBeforeTraverseEvent"
  3. Add a file subscriber.py with code to conditionally set the header X-Theme-Disabled: True  in case of edit domain (you may want to improve the condition).
    def surpress_theme(obj, event):
        if event.request['ACTUAL_URL'].startswith('http://edit.'):
            event.request.response.setHeader('X-Theme-Disabled', 'True')
  4. Restart your instance

To test this on localhost just add something like edit.localhost to your /etc/hosts file for and enter http://edit.localhost/Plone in your browser.

Image by karlbirrane at flickr under a CC-BY-SA license