GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Main page
  • Get MediaWiki
  • Get extensions
  • Tech blog
  • Contribute
  • User help
  • FAQ
  • Technical manual
  • Support desk
  • Communication
  • Developer portal
  • Code statistics
  • Community portal
  • Recent changes

This view

  • Original page
  • New address

GeezerVison is showing www.mediawiki.org — Snippets/Main Page tab - MediaWiki

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

Description

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.

Native

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.

Code

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 );
	}
} );

Alternative

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}}
Retrieved from "https://www.mediawiki.org/w/index.php?title=Snippets/Main_Page_tab&oldid=7953309"
Categories:
  • Snippets with JavaScript
  • All snippets
You are visitor 01402605 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.