Manual:Hooks/ArticlePageDataBefore

From MediaWiki.org
Jump to navigation Jump to search
ArticlePageDataBefore
Available from version 1.6.0
Executes before data is loaded for the article requested
Define function:
public static function onArticlePageDataBefore( $article, $fields, &$tables, &$joinConds ) { ... }
Attach hook:

In extension.json:

{
	"Hooks": {
		"ArticlePageDataBefore": "MyExtensionHooks::onArticlePageDataBefore"
	}
}

For MediaWiki ≤1.25:

$wgHooks['ArticlePageDataBefore'][] = 'MyExtensionHooks::onArticlePageDataBefore';
Called from:File(s): WikiPage.php

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

Details[edit]

  • $article: WikiPage object being requested.
  • $fields: fields to load from the database
  • &$tables: tables (array) to load from the database
  • &$joinConds: join conditions (array) to load from the database

As MediaWiki reads in the page data, this hook allows you to read more data fields related to the same database row than what is specified in WikiPage::selectFields(). You specify more data fields by adding them to $fields parameter. Such data fields can then be manipulated from ArticlePageDataAfter.