Manual:Hooks/GetContentModels

From MediaWiki.org
Jump to navigation Jump to search
GetContentModels
Available from version 1.29.0
Allows to add custom content handlers to the list of content models registered with the system.
Define function:
public static function onGetContentModels( &$models ) { ... }
Attach hook:

In extension.json:

{
	"Hooks": {
		"GetContentModels": "MyExtensionHooks::onGetContentModels"
	}
}

For MediaWiki ≤1.25:

$wgHooks['GetContentModels'][] = 'MyExtensionHooks::onGetContentModels';
Called from:File(s): ContentHandler.php

For more information about attaching hooks, see Manual:Hooks.
For examples of extensions using this hook, see Category:GetContentModels extensions.

Details[edit]

  • &$models: array of content model names. The extension should add its models to this array.

It is recommended that the extensions processing content models via ContentHandlerForModelID hook would register these models using this hook, otherwise the core does not know these models exist.

For more information on content models see ContentHandler.