Manual talk:$wgDefaultSkin
So, if a default skin is NOT SPECIFIED in $wgDefaultSkin, what skin is used? In my version of MediaWiki, $wgDefaultSkin is commented so a default skin is not set. Which one is used by default?
- The default value, shown in the infobox at the top of the page ('monobook' in this case) tells you what value will be used if you do not set a value in LocalSettings.php --HappyDog 14:01, 15 May 2006 (UTC)
[edit] Moved from Manual:LocalSettings.php
Aside from the standard Default Skin setting which is documented within the LocalSettings.php file: $wgDefaultSkin = 'monobook'; I've discovered this handy little hack for overriding the default skin based on the browser type. I found this trick to be especially handy after playing around with the new web browser on my Nintendo Wii. As font sizes for the default skin are fine for a computer screen, but much to small for a TV screen. Without a larger font you have to zoom and scroll far to much for a MediaWiki sites to be useful. I choose the "chick" skin, though the font size could still be a tad larger. You could also create a Wii (or whatever) skin to override with, I've done so by modifying the standard monobook skins main.css, scaling up the body from x-small to medium, and then scaling the personal and caction bars back down to fit the screen width.
Within LocalSettings.php add the following, including an optional note to modify the User.php file if you also wish to override a logged in users skin preferences, if not just skip that part.
# To Override skins based on browser type in includes/User.php change line 1042 or 1196
# from: $userSkin = $this->getOption( 'skin' );
# to: global $userSkin;
# to: if ( ! $userSkin ) { $userSkin = $this->getOption( 'skin' ); }
if ( preg_match( "/Nintendo Wii/i", $_SERVER['HTTP_USER_AGENT'] )) { $wgDefaultSkin = 'wii'; $userSkin = 'wii'; }
# Uncomment the following line for testing with a common browser type, chick is a good standard skin to try.
#if ( preg_match( "/Mozilla/i", $_SERVER['HTTP_USER_AGENT'] )) { $wgDefaultSkin = 'wii'; $userSkin = 'wii'; }
- This code can most likely be optimized further and may be more appropriate for another page here at MediaWiki, feel free to modify or move it... --D0li0 08:49, 18 January 2007 (UTC)
- I'm curious is this talk page is searched by anonymouse visitors looking for "HTTP_USER_AGENT" tricks like I was? BTW: This seems to work with v1.6, but not quite with v1.5 yet. --D0li0 23:45, 20 January 2007 (UTC)
- I've fixed the above block of code, adding the global line and inverting the if condition, which did but shouldn't have been working. Now the same modification works for v1.5, v1.6, and probably others. --D0li0 10:09, 21 January 2007 (UTC)
- I'd like to move this section into the main Manual:$wgDefaultSkin article as a new section named HTTP_USER_AGENT based skin choice, as that's what I'd be searching for if I were looking for a solution like this... I'll move it there in a few days if there are no objections. --D0li0 10:14, 21 January 2007 (UTC)
- I've fixed the above block of code, adding the global line and inverting the if condition, which did but shouldn't have been working. Now the same modification works for v1.5, v1.6, and probably others. --D0li0 10:09, 21 January 2007 (UTC)
- I'm curious is this talk page is searched by anonymouse visitors looking for "HTTP_USER_AGENT" tricks like I was? BTW: This seems to work with v1.6, but not quite with v1.5 yet. --D0li0 23:45, 20 January 2007 (UTC)
[edit] Is $wgDefaultSkin saved on account creation?
This manual page says
Note also that upon registration the value of $wgDefaultSkin is copied to the user preferences; thus setting it to another skin it won't have any effect on registered users, even if they never changed their preferences.
In 1.12 this does not seem to be the case. If I set $wgDefaultSkin to 'testskin' (which is a working skin) and then create an account, the skin is not saved. If I look in the database, the user.user_options field contains the line "skin=" -- i.e. a blank skin value. And if I subsequently change $wgDefaultSkin, the new user's skin changes to the new value of $wgDefaultSkin.
So either there's a bug in the code or there's a bug in the documentation. Personally, I would prefer it if the code did what the documentation says. This can be fixed by editing the initUser function in include/SpecialUserlogin.php:
--- SpecialUserlogin.php.orig 2008-06-26 00:34:29.000000000 +0000
+++ SpecialUserlogin.php 2008-06-26 00:34:08.000000000 +0000
@@ -330,7 +330,7 @@
* @private
*/
function initUser( $u, $autocreate ) {
- global $wgAuth;
+ global $wgAuth, $wgDefaultSkin;
$u->addToDatabase();
@@ -345,6 +345,7 @@
$wgAuth->initUser( $u, $autocreate );
$u->setOption( 'rememberpassword', $this->mRemember ? 1 : 0 );
+ $u->setOption( 'skin', $wgDefaultSkin );
$u->saveSettings();
# Update user count