|
Cookbook /
SkinChangeSummary: change skin via query or cookie setting
Version: 2007-02-19
Status: Stable
Prerequisites: pmwiki-2.0
Maintainer: Pm
Votes: 5
Question
AnswerThe skinchange.phpΔ script enables query parameters of the form
to be added to a page url to allow users to view pages with a different skin.
To use this script, download it into the cookbook directory of your installation. To allow browsers to use any skin already loaded into the skins directory, simply set $EnableAutoSkinList and include the recipe: $EnableAutoSkinList = 1;
include_once('cookbook/skinchange.php');
To restrict browsers to specific skins, create a $PageSkinList array mapping values for $PageSkinList = array(
'pmwiki' => 'pmwiki',
'classic' => 'myclassicskin',
'jh' => 'jhskin');
include_once('cookbook/skinchange.php');
These example links set the skin just for viewing a single page: These example links store a cookie in your browser so that all future visits to this site will show that skin. If $EnableAutoSkinList is also set, then entries in $PageSkinList take precedence. If a browser requests a skin that isn't available, then PmWiki defaults to the skin already defined by $Skin. By default, the setskin cookie that is created will expire after one year. You can set it to expire at the end of the browser session by setting $SkinCookieExpires=0; For wiki-code that will automatically generate a list of available skins, see SkinList. Skinchange and Wiki FarmsLike most other PmWiki customizations, instructions from more specific files override those from less specific files, in a chain like this:
Enable skinchange farmwide
Override skinchange for a particular field
Centrally manage the skin list, set default skin per field, and allow user to choose skin per field
Centrally manage the skin list, set default skin per field, and allow user to choose skin for entire farm
Automatic Browser Based Skin ChangeYou can also perform a skin change based on browser detection. Refer to WikiOnPDA. Change for One Session Only (or by time, or ....)To change the skin setting to a per-session one (cleared when browser closed), simply set: $SkinCookieExpires = 0;
You could also allow the expiration time as an options, by adding: if (isset($_REQUEST['skinexpires']))
$SkinCookieExpires = 0 + $_REQUEST['skinexpires'];
Then one can do ?setskin=foo&skinexpires=86400 to get the setting to last for 24 hours. Or, to be really fancy, perhaps: if (isset($_REQUEST['skinexpires'])) {
list($g0,$g1) = DRange($_REQUEST['skinexpires']);
$SkinCookieExpires = $g0;
}
Then one can actually use a real date for expiration, as in: ...?setskin=foo&skinexpires=2009-01-01
...?setskin=foo&skinexpires=tomorrow
CommentsNote: after PmWiki 2.2.x beta, pages in headers, footers, sidebars needs to use the * to reference the page variable of the page calling the sidebar/header/footer included files:
[[{*$Name}?skin=marathon]] etc. This is only used on pages that will be included in other pages when you want to use the variables from the current page, otherwise the $Name is Group/SideBar or Group/GroupHeaderContributors |