Manual:Hooks/CategoryPageView
Appearance
| CategoryPageView | |
|---|---|
| Available from version 1.4.3 Called before viewing a categorypage in CategoryPage::view | |
| Define function: | public static function onCategoryPageView( &$categoryPage ) { ... }
|
| Attach hook: | In extension.json:
{
"Hooks": {
"CategoryPageView": "MediaWiki\\Extension\\MyExtension\\Hooks::onCategoryPageView"
}
}
|
| Called from: | File(s): CategoryPage.php |
| Interface: | CategoryPageViewHook.php |
For more information about attaching hooks, see Manual:Hooks.
For examples of extensions using this hook, see Category:CategoryPageView extensions.
Details
[edit source]$categoryPage:CategoryPageinstance (CategoryPageis a subclass of Article)
If this method returns false, then the default behavior of CategoryPage::view will be skipped.
Notes
[edit source]- If there is a diff and
$diffOnlyis set, then the diff would be displayed and this hook won't be reached. - This hook is never accessed when previewing a page. The category listing is generated via
EditPage::showPreview()instead ofCategoryPage::view(). - An alternative way to modify the appearance of a category page is to use the ArticleFromTitle hook, and create a new
Articleobject using a custom class derived fromCategoryPage. This method allows the category page to be customized in both preview and standard view mode. See the CategoryTree extension for an example.