Manual:Hooks/GetContentModels

From Linux Web Expert

GetContentModels
<translate> Available from <tvar name=1><translate> version <tvar </tvar></translate>
Allows to add custom content handlers to the list of content models registered with the system.
<translate> Define function:</translate>
public static function onGetContentModels( &$models ) { ... }
<translate> Attach hook:</translate> <translate> In <tvar name=1>extension.json</tvar>:</translate>
{
	"Hooks": {
		"GetContentModels": "MediaWiki\\Extension\\MyExtension\\Hooks::onGetContentModels"
	}
}
<translate> Called from:</translate> <translate> File(s):</translate> ContentHandler.php
<translate> Interface:</translate> GetContentModelsHook.php

<translate> For more information about attaching hooks, see <tvar name=1>Manual:Hooks </tvar>.</translate>
<translate> For examples of extensions using this hook, see <tvar name=cat>Category:GetContentModels extensions</tvar>.</translate>


Details

  • &$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.