Display page sort key on MediaWiki page or footer

49 Views Asked by At

I need to display the MediaWiki page sort key on the page, or in the footer by using a template within MediaWiki:Lastmodifiedatby. The sort key can be either automatically defined or by using DEFAULTSORT.

I searched MediaWiki documentation for builtin variables as well as the Lua reference (no success for mw.title), and also searched for existing extensions providing the sort key, but were not successful so far.

Is there a way to derive and display the sort key of a MediaWiki page, by template or Lua code?

1

There are 1 best solutions below

0
On

You can create a template named DEFAULTSORT (or whatever) and use that instead of the magic word to intercept the call.

For example, this adds a <span> containing the sort key to the page:

{{DEFAULTSORT:{{{1|}}}|{{{2|}}}}}<span class="sortkey">{{{1|}}}</span>

And then you can just replace the : in previous usages with |:

{{DEFAULTSORT:Doe, John}}
{{DEFAULTSORT|Doe, John}}