Extension:NoTitle

From MediaWiki.org
Jump to: navigation, search
MediaWiki extensions manual - list
Crystal Clear action run.png
NoTitle

Release status: experimental

Implementation Extended syntax
Description Adds a magic word that lets you hide the main title heading
Author(s) Carlo Cabanilla, Tony Boyles
Latest version 0.2.0 (2013-05-15)
Database changes No
License GNU General Public License 3.0 or later
Download

See the installation section

Hooks used
LanguageGetMagic

ParserBeforeTidy

Translate the NoTitle extension if possible

Check usage and version matrix; code metrics

The NoTitle extension adds a magic word, __NOTITLE__, that lets you hide the main title heading on any page.

Put __NOTITLE__ on any pages where you want to hide the title. This extension will work for any skin that puts the title heading in an h1 with class="firstHeading", including the default Vector skin.

Installation[edit | edit source]

  1. In the existing extensions folder create a new folder named NoTitle.
  2. Create a text file called NoTitle.php.
  3. Copy and paste the below code to the NoTitle.php text file.
  4. Save the file. When saving the NoTitle.php file, make sure the file has the .php extension, not .txt.
  5. Move the file into the following path: extensions/NoTitle/NoTitle.php
  6. Add the following line to LocalSettings.php:
require_once "$IP/extensions/NoTitle/NoTitle.php";
Code
<?php

if ( !defined( 'MEDIAWIKI' ) ) {
        die( 'This file is an extension to MediaWiki and thus not a valid entry point.' );
}

$wgExtensionCredits['parserhook'][] = array(
        'name' => 'No Title',
        'version' => '0.2.0',
        'author' => array( 'Carlo Cabanilla', 'Tony Boyles', ),
        'description' => 'Provides a magic word that allows to hide the title heading of a page',
        'url' => 'https://www.mediawiki.org/wiki/Extension:NoTitle'
);

$wgHooks['LanguageGetMagic'][] = 'NoTitle::addMagicWordLanguage';
$wgHooks['ParserBeforeTidy'][] = 'NoTitle::checkForMagicWord';

class NoTitle {

        public static function addMagicWordLanguage( &$magicWords, $langCode ) {
                switch ( $langCode ) {
                        default:
                                $magicWords['notitle'] = array( 0, '__NOTITLE__' );
                }
                MagicWord::$mDoubleUnderscoreIDs[] = 'notitle';
                return true;
        }
 
        public static function checkForMagicWord( &$parser, &$text ) {
                if ( isset( $parser->mDoubleUnderscores['notitle'] ) ) {
                        $parser->mOutput->addHeadItem(
                                '<style type="text/css">.firstHeading, .subtitle, #siteSub, #contentSub, .pagetitle { display:none; }</style>'
                        );
                }
                return true;
        }

}

Thanks[edit | edit source]

This extension is being maintained by Tony Boyles through a project of Milcord llc.

See Also[edit | edit source]

Language: English  • 日本語