Manual:Hooks/ContentModelCanBeUsedOn

From Linux Web Expert

ContentModelCanBeUsedOn
<translate> Available from <tvar name=1><translate> version <tvar (Gerrit change 100563)</tvar></translate>

<translate> Define function:</translate>
public static function onContentModelCanBeUsedOn( $modelId, Title $title, &$ok ) { ... }
<translate> Attach hook:</translate> <translate> In <tvar name=1>extension.json</tvar>:</translate>
{
	"Hooks": {
		"ContentModelCanBeUsedOn": "MediaWiki\\Extension\\MyExtension\\Hooks::onContentModelCanBeUsedOn"
	}
}
<translate> Called from:</translate> <translate> File(s):</translate> content/ContentHandler.php
<translate> Function(s):</translate> canBeUsedOn
<translate> Interface:</translate> ContentModelCanBeUsedOnHook.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:ContentModelCanBeUsedOn extensions</tvar>.</translate>


Details

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.