Attention

This document was written for an unsupported version of Plone, Plone 2.5.x, and was last updated 1240 days ago.

For more information, see the version support policy.

To learn how to upgrade to the current version of Plone, read the upgrade manual.

Making a Skin Switch Last

by George Lee last modified Dec 30, 2008 03:05 PM
How to make a skin switch last beyond a single REQUEST and page view.

Because Plone determines the current skin on every page load, we need to make sure that any changes we make last.


Two of the above interventions are standard ways of changing underlying settings, ensuring that the skin switch lasts:

  • (2B.i) Use the ZMI to enable changing users' skin preferences. Then use the Plone personal preferences page to change a user's preferred skin, and thus automatically create a cookie with the skin name.
  • (3) Use the ZMI to change the default skin.


Two of the interventions involve changing underlying settings, but not in a standard way.

  • (2B.ii) Set a user's preferred skin outside of the preferences form, and update the cookie.
  • (2B.iii) Create a portal_skins cookie manually.

To do this, you should create a one-time script.


Finally, three of the interventions only make short-term changes that only last for the short lifetime of a single REQUEST:

  • (1A) Call object.changeSkin('mySkin').
  • (1B) Manually modify the SKINDATA variable.
  • (2B) Add 'portal_skin' to the REQUEST as a simple string attribute.

To make these changes sustainable, you must use a script that repeats on every page load. The typical way of doing this is using an Access Rule. See EnSimpleStaging Tutorial - Switching Skins By URL and Using Zope/Apache to Switch Skins By URL for examples of how to do this.


Contribute

Something wrong or out of date? Anybody can edit or create a new article in the knowledge base. Simply create an account on this site, log in, and click the Edit button to contribute.