|
Skins /
SkinChangeSummary: change skin via query or cookie setting
Version: pmwiki-2.3.37
Status: Stable
Prerequisites: pmwiki-2.0
Discussion: SkinChange-Talk
How can I allow users to change their skin based on a query parameter or cookie setting? Note, PmWiki 2.2.127 or newer already contains this feature, so you don't need to download a file and use an DescriptionThe feature enables query parameters of the form
to be added to a page url to allow users to view pages with a different skin.
In $EnableAutoSkinList = 1;
To restrict browsers to specific skins, create a $PageSkinList = array( 'pmwiki' => 'pmwiki', 'classic' => 'myclassicskin', 'jh' => 'jhskin'); include_once('cookbook/skinchange.php'); # Only for PmWiki 2.2.126 or older 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 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. NotesTo use this script for PmWiki 2.2.126 or older, place skinchange.phpΔ into the cookbook directory of your installation (newer PmWiki versions already contain the feature and you don't need to download and include the file). To allow browsers to use any skin already loaded into the skins directory, simply set $EnableAutoSkinList = 1; include_once('cookbook/skinchange.php'); # Only for PmWiki 2.2.126 or older The recipe should work with PHP 4 - PHP 7 on all PmWiki 2.2.x versions but PmWiki versions 2.2.105 or later can use secure cookies to store the visitors' preferences if this is desired. Release notes
Contributors
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/GroupHeader Question:
How do I create two links on the Side Bar (popupmenu) of Simple skin, that change the skin for the user, with the ?setskin= option ?One link might say "Desktop View" and the other "Mobile View". Preferably, the current page gets reloaded, instead of opening another page. nikos? February 08, 2019, at 02:58 PM You can add in the sidebar something like It works! Thanks. Question :
skinchange is useful but it adds something like How can i avoid the ?skin=simple To change the skin for all users, set in User notes : If you use, used or reviewed "SkinChange", you can add your name. These statistics appear in the Skins listings and will help newcomers browsing through the wiki. |