Manual:Hooks/ContentHandlerDefaultModelFor

From MediaWiki.org
Jump to: navigation, search
ContentHandlerDefaultModelFor
Available from version 1.21.0
Allows to control the content model a given title will default to.
Define function:
public static function onContentHandlerDefaultModelFor( Title $title, &$model ) { ... }
Attach hook:
$wgHooks['ContentHandlerDefaultModelFor'][] = 'MyExtensionHooks::onContentHandlerDefaultModelFor';
Called from: File(s): ContentHandler.php

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

Details[edit]

  • $title: Title for which the default content model is to be determined.
  • &$model: The desired model. A handler function can change this to control the model that will be used for the given title.

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.