Open main menu

Snippets/Main Page tab

< Snippets
How to use Snippets
List of Snippets
Crystal Clear action run.png
Main Page tab
Language(s): JavaScript
Compatible with: MediaWiki 1.17+ (Vector; Monobook)

Contents

DescriptionEdit

On the main page (and its associated namespaces and actions (Talk, edit, history etc.) this script will put "Main Page" instead of "Article" or "Page" in the first tab. Works in both Vector and Monobook.

NativeEdit

MediaWiki version: 1.18

If you are using 1.18 or higher, you can instead use the interface message "mainpage-nstab". You can do this by creating the page MediaWiki:mainpage-nstab on your wiki (requires administrator rights) with the desired label.

CodeEdit

MediaWiki version: 1.17
/**
 * MainPage tab
 *
 * @source mediawiki.org/wiki/Snippets/Main_Page_tab
 * @version 2014-07-30
 */
$( function() {
	var title = mw.config.get( 'wgTitle' ),
		hasMainPageTab = (title === 'Main Page'); // Title of the main page
	if ( hasMainPageTab ) {
		$( '#ca-nstab-main' ).find( 'a' ).text( title );
	}
} );

AlternativeEdit

The following requires $wgHtml5 to be set to true.

PageTab.js

/**
 * Page-tab
 * Replace "Article", "Page", or whatever in page/namespace tab with custom string
 *
 * @rev 1
 */

$( document ).ready( function () {
	var title = $.trim( $( '#mw-nstab' ).data( 'nstab' ) );
	if ( title !== '' ) {
		$('#ca-nstab-' + ( mw.config.get( 'wgCanonicalNamespace' ).toLowerCase() || 'main' ) ).find( 'a' ).text( title );
	}
} );

Template:Page_tab

<span id="mw-nstab" data-nstab="{{{1|}}}"></span>

Usage

{{Page tab|Awesome Tab}}