Jump to content

Manual:Hooks/ParserFetchTemplateData

From mediawiki.org
ParserFetchTemplateData
Available from version 1.35.0 (Gerrit change 494817)
Fetches template data for an array of template titles
Define function:
public static function onParserFetchTemplateData( array $titles, array &$ret ) { ... }
Attach hook: In extension.json:
{
	"Hooks": {
		"ParserFetchTemplateData": "MediaWiki\\Extension\\MyExtension\\Hooks::onParserFetchTemplateData"
	}
}
Called from: File(s): includes/parser/Parsoid/Config/DataAccess.php
Function(s): fetchTemplateData
Interface: ParserFetchTemplateDataHook.php

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


Parameters

[edit]
  • $titles: 1-dimensional array of strings, representing template titles
  • &$templateData: array map (contains key-value pairs) passed by reference, which can be modified by extensions to send their own template data

Use cases

[edit]

Currently, TemplateData uses this extension. TemplateData adds each template title to the $templateData map, and will assign one of the following values:

  • If a title is invalid title or is an invalid redirect title, gives a null value
  • If a title doesn't exist, will assign it a 'missing' key assigned with true
  • If a title has invalid data from the database, or does not have a 'templatedata' property in the page_props table, assign it as: (object)[ "notemplatedata" => true ]

Notes

[edit]