URL-dependent skinswitching in Plone 3
I was just about to explain to somebody via email how to switch skins per url in Plone 3 when I realised I should rather blog it and send him the link instead of just explain it to him privately, so here it goes...
Add a file skinswitcher.py to the top-level of your product with the following contents:
def setskin(site, event):
if event.request.URL.find('127.0.0.1') > -1 \
or event.request.URL.startswith('https'):
site.changeSkin('NuPlone', event.request)
then include the following snippet in your top-level configure.zcml:
<subscriber
for="Products.CMFPlone.interfaces.IPloneSiteRoot
zope.app.publication.interfaces.IBeforeTraverseEvent"
handler=".skinswitcher.setskin" />
This particular example simply enables the NuPlone skin when the site is accessed via https or 127.0.0.1 (instead of localhost) and otherwise uses the default skin which is my usecase 99% of the time but it should be easy now to modify skinswitcher.py to your particular needs.
