Manual:Hooks/ContentHandlerDefaultModelFor

From Linux Web Expert

ContentHandlerDefaultModelFor
<translate> Available from <tvar name=1><translate> version <tvar </tvar></translate>
Allows control over which content model a given title will default to.
<translate> Define function:</translate>
public static function onContentHandlerDefaultModelFor( MediaWiki\Title\Title $title, ?string &$model ) { ... }
<translate> Attach hook:</translate> <translate> In <tvar name=1>extension.json</tvar>:</translate>
{
	"Hooks": {
		"ContentHandlerDefaultModelFor": "MediaWiki\\Extension\\MyExtension\\Hooks::onContentHandlerDefaultModelFor"
	}
}
<translate> Called from:</translate> <translate> File(s):</translate> includes/Revision/MainSlotRoleHandler.php
<translate> Interface:</translate> ContentHandlerDefaultModelForHook.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:ContentHandlerDefaultModelFor extensions</tvar>.</translate>


Details

  • \Title $title: Title for which the default content model is to be determined.
  • ?string &$model: The desired model. A handler function can change this to control the model that will be used for the given title. Usually uses one of the CONTENT_MODEL_xxx constants.

Return false to bypass any built-in rules for determining the model, such as the file extensions ".js" and ".css" on user subpages. Return true to keep applying these rules.

For more information on content models see ContentHandler, and for a tutorial about creating content models in extensions, see Manual:Page content models.