Page MenuHomePhabricator

Template links on article preview page should be in alphanumeric (alphabetic) order
Closed, ResolvedPublic

Description

Author: greg.ebdon

Description:
See also bug 12532, and bug 12532, comment 4.

Basically, it would be very useful if the links to all the templates used in a page could be sorted in alphanumeric order for ease of finding a particular one. Obviously they're all in the same namespace, so just the BASEPAGENAME needs to be sorted. IIRC, they're currently in a random order - it might also be possible to have either a small link or an option in preferences to put them in the order they're used in the page.


Version: 1.12.x
Severity: enhancement

Details

Reference
bz12644

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 10:02 PM
bzimport set Reference to bz12644.
bzimport added a subscriber: Unknown Object (MLST).

They aren't necessarily in the same namespace. You can transclude a page from any namespace and it'll show up in the template list.

greg.ebdon wrote:

(In reply to comment #1)

They aren't necessarily in the same namespace. You can transclude a page from
any namespace and it'll show up in the template list.

This is true... I hadn't thought of that. Another I was planning to ask was if a feature could be implemented to link to substed templates on a preview page as well (e.g. if you've added a template in your current edit, you have to remove the subst: to get it to show up in the list, then replace it when saving. You think that might be useful?

Created attachment 4590
Patch to Linker.php as of r30183

I'm not sure if this works. It seems almost /too/ easy. Can someone more
familiar with this part of the code take a look? Thanks.

Attached:

greg.ebdon wrote:

(In reply to comment #3)

Created an attachment (id=4590) [details]
Patch to Linker.php as of r30183

I'm not sure if this works. It seems almost /too/ easy. Can someone more
familiar with this part of the code take a look? Thanks.

Whether with ^demon's patch or not, this feature seems to have been implemented - look at a few multi-template articles to confirm. Can someone confirm this code-wise and mark the bug resolved, please?

They'll be sorted on initial view because they're pulled from the database in indexed order; but on preview, they'll appear in the order of parsing.

(The previously attached patch doesn't work for two reasons: sort() doesn't return a value, breaking the array, and the sorting doesn't handle the title objects correctly.)

Fixed in r34485.

On initial edit, items were sorted by virtue of being pulled from a sorted table, but on preview they were displayed in rough order of use in parsing, which is a bit less legible.

Added Title::compare() static comparator available as a callback for usort(), using it in Linker::formatTemplates().

  • Bug 19426 has been marked as a duplicate of this bug. ***