Manual:Hooks/GetDefaultSortkey
From MediaWiki.org
| GetDefaultSortkey | |
|---|---|
| Available from version 1.18.0 (r91510) Called when determining what the default sortkey would be for a page |
|
Define function: |
public static function onGetDefaultSortkey( $title, &$sortkey ) { ... }
|
Attach hook: |
$wgHooks['GetDefaultSortkey'][] = 'MyExtensionHooks::onGetDefaultSortkey'; |
| Called from: | Title.php |
For more information about attaching hooks, see Manual:Hooks.
For examples of extensions using this hook, see Category:GetDefaultSortkey extensions.
Details [edit]
- $title: A Title object representing the page in question
- &$categoryObj: What sortkey to use unless a custom one is specified. If a custom sortkey was specified, this value would be used as a tie breaker for the specified sortkey.
Notes [edit]
After adding an extension that uses this hook, you should run php updateCollations.php --force to re-sort any existing category entries. What the default sortkey for a page is, is not stored in the DB, so things won't get updated until the category is removed and re-added to a page, or the maintenance script is run.
This should not use any information that could change other then the title object, because such sortkeys are only re-calculated on page moves or if the category is removed and re-added.