Last modified: 2012-01-26 15:27:34 UTC
Please add a constant {{DEFAULTSORT}} It should just get the value that was set by {{DEFAULTSORT:value}}, if any. If {{DEFAULTSORT}} has been used, and the value is thus set, it will be helpful to be able to use it inside templates, e.g. so as to superceede a sort key that the template would be using otherwise.
Adding some precision: {{DEFAULTSORT:xyz}} - sets default sort key. We have that already. New would be these: {{DEFAULTSORT}} - renders nothing if no default sort key is set for the page. {{DEFAULTSORT}} - yields the default sort key if one is set for the page. {{DEFAULTSORT|xyzzy}} - renders "xyzzy" if no default sort key is set for the page. {{DEFAULTSORT|zyx}} - yields the default sort key if one is set for the page. The latter two resemble parameter references in templates, thus, inside templates you can do something like: [[category:foo|{{{bar | {{DEFAULTSORT | {{PAGENAME}} }} }}}]] which may come handy.
I am also running into the need for integration of the parameter references in the templates. If the possibility for the DEFAULTSORT to be utilized in or with parser functions it would also be extremely helpful. If nothing else, allow the [[category:foo|{{{bar | {{DEFAULTSORT | {{PAGENAME}} }} }}}]]. I'm fairly surprised this has taken this long to be addressed as the DEFAULTSORT key is used commonly in categorization.
I'm thinking something like this should perhaps be named something different than {{DEFAULTSORT}} to avoid confusion (and potentially open up the possibility of {{DEFAULTSORT:some other page}} syntax later if that's deemed useful), but can't come up with any good names ({{GETDEFAULTSORTKEY}} but nothing else uses get...). Maybe keeping the same name would be ok...
In r96767 (MediaWiki 1.19) I added a feature to defaultsortkey: {{DEFAULTSORTKEY:sortkey here|noreplace}} which will cause defaultsortkey to do nothing if a sortkey is already specified earlier in the page. With that in mind, are there still use cases for a {{DEFAULTSORTKEY}} variable that would output what the last defaultsortkey set was?
At the moment, I do not have a compelling real life use case, but mileage may vary... It might be useful inside templates, e.g. when referring to entries in sorted tables using the sort key: [{{fullurl:...}}#{{DEFAULTSORTKEY}} list entry]