Plone skin switching by inspecting the URL
Does your site have one view for the public interface and another for the admin interface? Then you should serve different skins depending on the URL.
Plone's CSS and main_template and friends are not easily adapted to very specific public interfaces. In such a case it is better to serve a skin called say Public to normal site visitors and Plone Default to administrators. I assume you know how to create these skins.
Now you need to know which skin to serve. Let http://www.foo.com be the URL for use by normal site visitors, and http://admin.foo.com be the URL for use by site administrators.
We are going to use an External Method and a Set Access Rule to accomplish this.
In your product's Extension directory create a file called selectSkin.py
# Contents of selectSkin.pyAdd this snippet to Install.py or AppInstall.py. Replace MyProduct with the name of your product.
def run(self):
request = self.REQUEST
if request.get('URL').startswith('http://admin'):
self.portal_url.getPortalObject().changeSkin('Plone Default')
else:
self.portal_url.getPortalObject().changeSkin('Public')
from Products.SiteAccess.AccessRule import manage_addAccessRuleBrowse to your site via different URLs and you'll see it in action.
if not hasattr(self, 'selectSkin'):
em = self.manage_addProduct['ExternalMethod']
em.manage_addExternalMethod('selectSkin', 'selectSkin', 'MyProduct.selectSkin', 'run')
manage_addAccessRule(self, 'selectSkin')






