Snippets/Multi-column sorted categories

Instead of an unreadable old-style, concatenated, unsorted, long list of categories you can now choose to display your page categories as a modern, multi-column, sorted table.

How to use Snippets
List of Snippets
Multi-column sorted categories
Language(s): PHP
Compatible with: MediaWiki 1.27 (or earlier)+ (all)

A really nice and readable layout for MediaWiki page categories. Very easy to implement.

Simple PHP patch

edit

Patch valid for MediaWiki 1.27, or earlier. You only have to change 5 lines of code.

rcsdiff -u includes/skins/Skin.php
RCS file: includes/skins/RCS/Skin.php,v
retrieving revision 1.1
diff -u -r1.1 includes/skins/Skin.php
--- includes/skins/Skin.php 2017/09/30 18:41:49 1.1
+++ includes/skins/Skin.php 2017/09/30 19:27:04
@@ -442,14 +442,16 @@
$colon = $this->msg( 'colon-separator' )->escaped();

if ( !empty( $allCats['normal'] ) ) {
- $t = $embed . implode( "{$pop}{$embed}", $allCats['normal'] ) . $pop;
+$gvpCat =$allCats['normal'];
+asort($gvpCat);
+ $t = implode( '<br>', $gvpCat ) ;

$msg = $this->msg( 'pagecategories' )->numParams( count( $allCats['normal'] ) )->escaped();
$linkPage = wfMessage( 'pagecategorieslink' )->inContentLanguage()->text();
$title = Title::newFromText( $linkPage );
$link = $title ? Linker::link( $title, $msg ) : $msg;
- $s .= '<div id="mw-normal-catlinks" class="mw-normal-catlinks">' .
- $link . $colon . '<ul>' . $t . '</ul>' . '</div>';
+ $s .= $link . ':<br><div id="mw-normal-catlinks" class="mw-normal-catlinks" >' .
+ $t . '</div>';
}

Small change in CSS

edit

Edit MediaWiki:Common.css

.mw-normal-catlinks {
	column-count:6;
}