Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

MediaWiki Developer's Handbook/Adding new tags

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

To create a parser extension for a new tag just requires a few lines of code: <? php if( !defined( 'MEDIAWIKI' ) ) { die( "This file is part of MediaWiki and is not a valid entry point\n" ); } $wgExtensionFunctions[] = 'myNewTagInit'; $wgExtensionCredits['myNewTag'][]= array( 'name' => 'myNewTag Extension', 'version' => '1.0.0', 'author' => 'Your Name', 'url' => 'http://www.your.com/mynewtag/', 'description' => 'This extension is for demonstration only.'); function myNewTagInit() { global $wgParser; $wgParser->setHook( "myNewTag", "myNewTagParse" ); } function myNewTagParse($content, $params, $parser ) { return "My ''''fancy'''' output"; } ?> For testing create a subdirectory mediawikipath/extensions/mynewtag. Save the coding there as myNewTag.php. Add the following line to LocalSettings.php: require_once "$IP/extensions/mynewtag/myNewTag.php"; Now create a new mediawiki page <mynewtag /> and save it. The output will look like this: My 'fancy' output