Extension:HideSidebar

From MediaWiki.org
Jump to: navigation, search

This extension suppresses display of the sidebar from anonymous users. Cribbed from Manual:Interface/Sidebar#Change sidebar content when logged in .28PHP.29.

MediaWiki extensions manual - list
Crystal Clear action run.png
HideSidebar

Release status: beta

Implementation Skin
Description Hide sidebar from anonymous users
Author(s) JlernerTalk
Last version 1.0.1 (2011-09-07)
MediaWiki 1.14+
License GPL 2 or later
Download below
Hooks used
SkinBuildSidebar

Check usage (experimental)

Contents

[edit] Download instructions

Please cut and paste the code found below and place it in $IP/extensions/HideSidebar/HideSidebar.php. Note: $IP stands for the root directory of your MediaWiki installation, the same directory that holds LocalSettings.php.

[edit] Installation

To install this extension, add the following to LocalSettings.php:

require_once("$IP/extensions/HideSidebar/HideSidebar.php");

[edit] Configuration parameters

[edit] User rights

[edit] Code

<?php
 
if ( !defined( 'MEDIAWIKI' ) ) {
        echo "Not a valid entry point";
        exit( 1 );
}
 
$wgExtensionCredits['other'][] = array(
        'path' => __FILE__,
        'name' => 'HideSidebar',
        'version' => '1.0.1',
        'author' => 'Jlerner',
        'url' => 'http://www.mediawiki.org/wiki/Extension:HideSidebar',
        'description' => 'Allows to hide the sidebar from anonymos users',
);
 
$wgHooks['SkinBuildSidebar'][] = 'efHideSidebar';
 
function efHideSidebar($skin, &$bar) {
        global $wgUser;
        // Hide sidebar for anonymous users
        if (!$wgUser->isLoggedIn()) {
                $url = Title::makeTitle(NS_SPECIAL, wfMsg('login'))->getLocalUrl();
                $bar = array(
                        'navigation' => array(
                                array('text'   => 'Login',
                                      'href'   => $url,
                                      'id'     => 'n-login',
                                      'active' => '')
                        )
                );
        }
        return true;
}

[edit] See also

Personal tools
Namespaces

Variants
Actions
Navigation
Support
Download
Development
Communication
Print/export
Toolbox