Extension:CorrectMainPageTitle

From MediaWiki.org
Jump to: navigation, search
MediaWiki extensions manualManual:Extensions
Crystal Clear action run.png
CorrectMainPageTitle

Release status:Extension status beta

ImplementationTemplate:Extension#type User interface
DescriptionTemplate:Extension#description Corrects the main page HTML title.
Author(s)Template:Extension#username VittGamtalk
Latest versionTemplate:Extension#version 1.1 (2010-10-14)
MediaWikiTemplate:Extension#mediawiki Tested on 1.16.0
PHPTemplate:Extension#php Tested on 5.3.3
LicenseTemplate:Extension#license GNU General Public License 3.0 or later
Download See below
Hooks usedTemplate:Extension#hook
MediaWikiPerformActionManual:Hooks/MediaWikiPerformAction

Translate the CorrectMainPageTitle extension if it is available at translatewiki.net

Check usage and version matrix.

This extension puts the correct HTML title in the main page, like in Wikimedia wikis.

Download instructions[edit]

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

Installation[edit]

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

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

Changelog[edit]

  • Version 1.0, 2010-08-27
    • First release

Code[edit]

<?php
# CorrectMainPageTitle v1.1
# Copyright (C) 2010 VittGam (www.VittGam.net)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
if (!defined('MEDIAWIKI')) {die('Not a valid entry point.');}
$wgExtensionCredits['other'][]=array(
	'name'=>'CorrectMainPageTitle',
	'author'=>'[http://www.VittGam.net/ VittGam]',
	'version'=>'1.1',
	'url'=>'http://www.mediawiki.org/wiki/Extension:CorrectMainPageTitle',
	'description'=>'Corrects the main page HTML title.'
);
$wgHooks['MediaWikiPerformAction'][]='CorrectMainPageTitle';
function CorrectMainPageTitle($output,$article,$title,$user,$request,$wiki) {
	if (in_array(strtolower($request->getText('action')),array('','view','print','submit','purge')) && $title->getText()==wfMsg('mainpage')) {
		$output->setHTMLTitle(wfMsg('pagetitle-view-mainpage'));
	}
	return true;
}