From mediawiki.org
MediaWiki extensions manual
OOjs UI icon advanced-invert.svg
Release status: unmaintained
Implementation Parser function
Description Adds a {{#promoted:status|langcode}} function to customize the look of interlanguage links to foreign promoted articles
Author(s) Nicolas Dumazet (NicDumZtalk)
License LGPL
Download No link

Check usage and version matrix.

What can this extension do?[edit]

This extension provides the ability to append predefined CSS classes to interlanguage links that got promoted status (featured articles, good articles, featured portals...) in other languages. This extension associates promoted statuses to CSS classes, and adds a {{#promoted:status|lang}} parser tag.

That extension is meant as an alternative to the JavaScript hacks used on the Wikimedia projects to display golden stars next to the interlanguage links pointing to a featured article in a foreign language.


Assuming that a "FA" CSS class is defined and included by MediaWiki e.g.:

li.FA {
    /* use a custom list bullet, for example */
    list-style-image: url("http://upload.wikimedia.org/wikipedia/en/d/d4/Monobook-bullet-star.png");

and that the featured status is associated to the FA CSS class (see below), adding {{#promoted:featured|fr}} to an article will apply the FA CSS class to the fr: interlanguage links in that article.

Download instructions[edit]

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


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

$wgPilPromotedClasses = array();

# Add a value to $wgPilPromotedClasses to add a promoted status.
# First key is the namespace where it applies
# Second key is the first {{#promoted argument expected
# Value is the CSS class to be appended to the promoted interlanguage link

# For instance, 
# $wgPilPromotedClasses['NS_MAIN']['featured'] = 'FArticle';
# $wgPilPromotedClasses['NS_MAIN']['good'] = 'GArticle';
# $wgPilPromotedClasses['NS_PROJECT']['featured'] = 'FPortal';
# creates three promoted statuses : Featured articles, good articles,
# and featured portals.
# In main namespace articles, {{#promoted:featured|xx}} will append the 
# FArticle CSS class to the xx: interlanguage links, {{#promoted:good|yy}}
# will append the GArticle CSS class to the yy interlanguage links

$wgPilPromotedClasses[NS_MAIN]['featured'] = 'FA';





if( !defined( 'MEDIAWIKI' ) ) {
	echo( "This file is an extension to the MediaWiki software and cannot be used standalone.\n" );
	die( 1 );


$wgExtensionCredits['parserhook'][] = array(
	   'name' => 'PromotedInterlanguages',
	   'author' =>'Nicolas Dumazet', 
	   'url' => 'http://www.mediawiki.org/wiki/Extension:PromotedInterlanguages', 
	   'description' => '<nowiki>{{#promoted:status|langcode}}</nowiki> parser tag, enhances look of interlanguage links that have a featured or good article status'

$wgPilInstance = new PromotedInterlanguagesHandler;

$wgHooks['SkinTemplateOutputPageBeforeExec'][] = array( $wgPilInstance, 'modifyInterlanguages' );

$wgExtensionFunctions[] = 'PromotedInterlanguages_Setup';

$wgHooks['LanguageGetMagic'][] = 'PromotedInterlanguages_Magic';

function PromotedInterlanguages_Setup() {
		global $wgParser, $wgPilInstance;
		$wgParser->setFunctionHook( 'promoted', array( $wgPilInstance, 'promotedTagRender' ) );

function PromotedInterlanguages_Magic( &$magicWords, $langCode ) {
		$magicWords['promoted'] = array( 0, 'promoted' );
		return true;



if( !defined( 'MEDIAWIKI' ) ) {
	echo( "This file is an extension to the MediaWiki software and cannot be used standalone.\n" );
	die( 1 );

class PromotedInterlanguagesHandler {

	# Stores the css classes to append.
	# Keys are language codes, values are css classes
	var $featuredBits = array();

	function promotedTagRender( &$parser, $type = '', $lang = '' ) {
		global $wgPilPromotedClasses, $wgTitle;


   		if ( isset( $wgPilPromotedClasses[$wgTitle->getNamespace()][$type] ) ) {
   			$this->featuredBits[$lang][] = 
		return "";
	function modifyInterlanguages($skin, $tpl) {

		if ( empty( $this->featuredBits ) ) {
			return true;

		global $wgOut, $wgContLang;

		$interlanguages =& $tpl->data['language_urls'];
		$i = 0;
		foreach( $wgOut->getLanguageLinks() as $l ) {
			$tmp = explode( ':', $l, 2 );
			$lang = $tmp[0];
			if ( isset( $this->featuredBits[$lang] ) ) {
				foreach( $this->featuredBits[$lang] as $class ) {
					$interlanguages[$i]['class'] .= " " . $class;
		return true;

See also[edit]