Extension:CategorySortHeaders

From MediaWiki.org
Jump to: navigation, search
MediaWiki extensions manualManual:Extensions
Crystal Clear action run.png
CategorySortHeaders

Release status:Extension status stable

ImplementationTemplate:Extension#type Hook
DescriptionTemplate:Extension#description Make custom headings in category pages, instead of just the first character headings
Author(s)Template:Extension#username Brian Wolff (Bawolfftalk)
Latest versionTemplate:Extension#version 0.2 (2011-07-05)
MediaWikiTemplate:Extension#mediawiki 1.19 (1.17 with small patch)
Database changesTemplate:Extension#needs-updatephp No
LicenseTemplate:Extension#license GNU General Public License 2.0 or later
Download
ParametersTemplate:Extension#parameters
  • $wgCategorySortHeaderAppendPageNameToKey
Hooks usedTemplate:Extension#hook
Collation::factoryManual:Hooks/Collation::factory

Translate the CategorySortHeaders extension if it is available at translatewiki.net

Check usage and version matrix.

The CategorySortHeaders extension to allow specifying custom multi-character 'first-character' sorting headers to list pages under in categories, using syntax like [[category:Foo|^Header^Invisible part of sortkey]] or even just [[category:Foo|^Header^]].

Usage[edit]

If you want a category to use a custom header, do [[category:Cat name|^header^OptionalInvisibleSortkey]] (or {{DEFAULTSORT:^header^Optionalsortkey}}. If you want to use the default first letter headers, just use categories as normal.

Download instructions[edit]

This extension requires MediaWiki 1.19. On 1.17 and 1.18 this extension works with one small patch (See below)

Installation[edit]

To install this extension, add the following to LocalSettings.php:

require_once( "$IP/extensions/CategorySortHeaders/CategorySortHeaders.php" );
  • Run either update.php or updateCollation.php from the command line (Note, running the web installer in upgrade mode does not work due to bugzilla:17335)
Warning Warning: Do not set $wgCategoryCollation in LocalSettings.php. This extension defines its own collation, and must use that.

Configuration[edit]

This extension has a single configuration option - $wgCategorySortHeaderAppendPageNameToKey. It defaults to true, which causes a sortkey of ^foo^ to be treated like ^foo^{{PAGENAME}}. If it is set to false, it will sort ^foo^ above ^foo^<any string here>. (In both cases, if there are two exactly same sort keys, the pagename will be used as a tie breaker). After changing this option you should run php updateCollations.php --force


If anyone likes the idea of this extension, but wants to use the uca-default collation instead of uppercase - let me (bawolff) know. It probably wouldn't be very difficult to modify this extension to make it work with uca-default

On MediaWiki 1.17 and 1.18[edit]

MediaWiki version: 1.18

This extension needs rev:91436 (included in MediaWiki 1.19 and higher) to work. Basically on MediaWiki 1.17 and 1.18 you just need to add the following to includes/Collation.php (replace the function factory with the following):

        static function factory( $collationName ) {
                switch( $collationName ) {
                        case 'uppercase':
                                return new UppercaseCollation;
                        case 'uca-default':
                                return new IcuCollation( 'root' );
                        default:
                                # Provide a mechanism for extensions to hook in.
				$collationObject = null;
				wfRunHooks( 'Collation::factory', array( $collationName, &$collationObject ) );

				if ( $collationObject instanceof Collation ) {
					return $collationObject;
 				}

				// If all else fails...
				throw new MWException( __METHOD__.": unknown collation type \"$collationName\"" );
                }
        }

(Or alternatively just apply the changes in rev:91436)

See also[edit]