Open main menu

Manual:Hooks/ContentModelCanBeUsedOn

< Manual:Hooks
ContentModelCanBeUsedOn
Available from version 1.23.0 (Gerrit change 100563)

Define function:
public static function onContentModelCanBeUsedOn( $modelId, Title $title, &$ok ) { ... }
Attach hook:

In extension.json:

{
	"Hooks": {
		"ContentModelCanBeUsedOn": "MyExtensionHooks::onContentModelCanBeUsedOn"
	}
}

For MediaWiki ≤1.25:

$wgHooks['ContentModelCanBeUsedOn'][] = 'MyExtensionHooks::onContentModelCanBeUsedOn';
Called from:File(s): content/ContentHandler.php
Function(s): canBeUsedOn

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

DetailsEdit

This hook is called by ContentHandler::canBeUsedOn() to determine whether a certain content model can be used on a certain title or not. This is checked, for example, on import or when moving pages .

  • $modelId: The content model ID, e. g. 'wikitext' or 'json'.
  • $title: The title where the content model may or may not be used.
  • &$ok: Whether the content model can be used on the title or not. Initially true; when you set this to false, you probably also want to return false; to skip the remaining hooks.