Page MenuHomePhabricator

Provide a way to alter page titles in category listings, e.g. via display title
Open, HighPublicFeature

Description

Original feature request: "There should be a way to not use the actual page titles but something else instead in the category listing. Would be useful for example translated titles."

Longer version:

In categories, the unformatted page name of a page is displayed. This is not especially desirable:

Names of pages should be formatted according to orthographic convention, and so they are consistent with the article's title. Most here will be familiar with italicising names of books and movies, ships, etc. https://en.wikipedia.org/wiki/Wikipedia:Manual_of_Style/Titles_of_works

This is a major issue. {{DISPLAYTITLE}} is used on (I conservatively estimate) about 20% of English Wikipedia pages, meaning this impacts more than 1 million pages on English Wikipedia alone. There is justification for arguing that this is currently the single biggest display-related issue in MediaWiki. It's reasonable to bump this up to High priority.

There are also cases where changing the page name displayed in a category may be useful:

  • To hide the namespace part of a page's name in a category. This part is often redundant, and can be ugly.
  • To override a technical restriction on the displayed page name. This is not presently how Wikipedia does it, but there may be some advantages to this approach, and other wikis may wish to do this, even if Wikipedia is resistant.
  • etc
  • The original report here (which is very short and hand-wavy) talks about how to deal with multiple languages. Wikimedia Commons doesn't handle multiple languages particularly well. Showing translated page and category names might be a little more complicated that outlined here, and potentially should be a subbug.

Solution 1

The first solution would be to use the {{DISPLAYTITLE}} value of a page. However, there are disadvantages to this; notably, it would generate a one-to-many relationship whereby the {{DISPLAYTITLE}} value would be used for two different things (even if usually related), and would always be displayed in categories. But there is potential that displayed name change is only desired in some of these categories. Nevertheless, this might probably be easiest/quickest to implement.

It offers some option to change the language if {{DISPLAYTITLE}} were set to be language-dependent.

Solution 2

An alternative solution would be to set a new value, suggest {{DISPLAYCAT}}, which will serve as the default value for display in categories. This can be set in the Wikitext in the same way as {{DEFAULTSORT}}. For example, {{DISPLAYCAT:USS ''Enterprise''}} would set the display to USS Enterprise. If {{DISPLAYCAT}} is not set, it should default to {{PAGENAME}}. There might have to be a $wgRestrictDisplayCat setting if people are too scared of vandals changing the displayed name (though with automatic tagging of changes to this, is this really necessary?)

For display in individual categories, I suggest using the pipe trick. Currently, the first entry after the pipe overrides {{DEFAULTSORT}} for that category, e.g. in [[Category:Foo|bar]]. If another pipe is added here, we can get to [[Category:Foo|bar|''qzzy'']] where qzzy is displayed as the page's title in [[category:Foo]]. If a double pipe is used, {{DEFAULTSORT}} would be used for sorting by default, e.g. [[category:foo||''qzzy'']] would sort under Foo. And if only the first pipe is present, e.g. [[category:foo]] then it would use {{DISPLAYCAT}} if defined elsewhere, or Foo if not, for backwards compatibility.

This offers maximum flexibility, and the possibility that some language-dependent variable could be set within the second pipe and displayed if the user's language differs from the default English value.

As far as I can tell, there should be nothing in here that's logically impossible or too resource-intensive. All the required code is already used either in the {{DISPLAYTITLE}} or {{DEFAULTSORT}} features.

Details

Reference
bz29975

Related Objects

Event Timeline

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

Would be very useful to me at the moment. I'm having a discussion about a custom namespace on a wiki I administrate, and the major concern seems to that the pages in the namespace show up as NS:foo instead of just foo on the category pages.

I cogitated a workaround that seems to work for me in css..
There has to be a better way though....

/* strip "NS:" namespace from category pages fix */
a[title^='NS:'] {

font-family: 'Lucida Grande', Geneva, Arial, Verdana, monospace; /*your font(s) +", monspace"*/
font-size: 12px; /*Set to whatever font-size those items currently use*/
display: inline-block;
overflow: hidden;
text-indent: -1.5em; /*fudge this number until your namespace prefix disappears*/

}
/* strip "NS:" namespace from category pages fix end */

(In reply to comment #2)

I cogitated a workaround that seems to work for me in css..
There has to be a better way though....

/* strip "NS:" namespace from category pages fix */

div#mw-pages /*declare the category listing section*/

a[title^='NS:'] {

font-family: 'Lucida Grande', Geneva, Arial, Verdana, monospace; /*your

font(s) +", monspace"*/

font-size: 12px; /*Set to whatever font-size those items currently use*/
display: inline-block;
overflow: hidden;
text-indent: -1.5em; /*fudge this number until your namespace prefix

disappears*/
}
/* strip "NS:" namespace from category pages fix end */

(In reply to comment #2)

I cogitated a workaround that seems to work for me in css..
There has to be a better way though....

/* strip "NS:" namespace from category pages fix */
a[title^='NS:'] {

font-family: 'Lucida Grande', Geneva, Arial, Verdana, monospace; /*your

font(s) +", monspace"*/

font-size: 12px; /*Set to whatever font-size those items currently use*/
display: inline-block;
overflow: hidden;
text-indent: -1.5em; /*fudge this number until your namespace prefix

disappears*/
}
/* strip "NS:" namespace from category pages fix end */

That's disgusting :P

(In reply to comment #4)

(In reply to comment #2)

I cogitated a workaround that seems to work for me in css..
There has to be a better way though....

/* strip "NS:" namespace from category pages fix */
a[title^='NS:'] {

font-family: 'Lucida Grande', Geneva, Arial, Verdana, monospace; /*your

font(s) +", monspace"*/

font-size: 12px; /*Set to whatever font-size those items currently use*/
display: inline-block;
overflow: hidden;
text-indent: -1.5em; /*fudge this number until your namespace prefix

disappears*/
}
/* strip "NS:" namespace from category pages fix end */

That's disgusting :P

Yes, but it visually worked.. For those that can use JavaScript, there is an alternative:

/*
Namespace Stripping
Fix by DDOwiki User:Ague
20 April 2012
*/
$('a[title^="Item:"]').each(function() {

this.innerHTML = this.innerHTML.replace("Item:", "");
this.title = this.title.replace("Item:", "");

})
/* Leave final semi-colon out. When MW parses this, for some reason it automatically adds a semi-colon. */

/* Optionally, un-comment the code below to strip the Item: from the page title as well.

MAKE SURE TO ADD THE SEMI-COLON AFTER THE }) ABOVE IF YOU UN-COMMENT BELOW! */

/*
$('h1#title').each(function() {

this.innerHTML = this.innerHTML.replace("Item:", "");

});
$('title').each(function() {

this.innerHTML = this.innerHTML.replace("Item:", "");

})
*/

Could {{DEFAULTSORT}} be modified to do this?

(In reply to comment #6)

Could {{DEFAULTSORT}} be modified to do this?

This bug is about giving this possibility in core, not about providing an interface for it. For instance, it would be used by bug 29928.

(In reply to comment #6)

Could {{DEFAULTSORT}} be modified to do this?

I think it would be possible to write an extension that would use defaultsort to do that, but it would be hacky beyond hacky so I wouldn't reccomend it.

(In reply to Bawolff (Brian Wolff) from comment #8)

I think it would be possible to write an extension that would use
defaultsort to do that, but it would be hacky beyond hacky so I wouldn't
reccomend it.

Display title / DISPLAYTITLE (which by default is restricted to case changes) is probably the most sensible property to reuse so I'm marking it as blocker, but this bug may be solved in other ways as well, as long as it allows Translate to set/use it (bug 29928).

Aklapper changed the subtype of this task from "Task" to "Feature Request".Feb 4 2022, 12:24 PM
Aklapper removed a subscriber: wikibugs-l-list.

Sorry for the duplicate bug.

Suggest that a new magic word {{DISPLAYCAT}} be created.

Suggest can duplicate most of the code for this from that for {{DISPLAYTITLE}}, including restrictions in localsettings.php

Often the value will be the same as the {{DISPLAYTITLE}} value, but probably not always and some might like to remove the namespace or replace NS with emoji. (Project categories can get very ugly if they ate filled with Project:this and Project:that). So it should be independent of {{DISPLAYTITLE}}.

Another way should also be found to mark redirects in categories rather than italicising them. Suggest adding (redirect) after the pagename.

Forget about {{DEFAULTSORT}} that's totally different.

The community will find a way to populate the {{DISPLAYCAT}} magic word quickly.

Pps actually there may be some relevant code in {{DEFAULTSORT}} -- the category page fetches the {{DEFAULTSORT}} values of all its members. It will also need to fetch the {{DISPLAYCAT}} values for each of those members and then display those values in lieu of the pagename. If that makes sense.

And this bug is 10 years old....? It should be higher priority because it affects the public view of the wiki.

FWIW, my comment above was directed at my original submission at https://phabricator.wikimedia.org/T326059 which goes into a lot more detail as to why this is important. I think it’s worth repeating that specifically here:

At present, within categories, pages are displayed by their name. That means various formatting of the page titles is ignored:

  • Book and film titles don’t appear in italics.
  • Ship names don't appear in italics.
  • Trademark names beginning with a lower case letter like [eBay] have their first letter capitalised.
  • bell hooks becomes Bell hooks.
  • Some linguistics-related titles should have ꜱᴍᴀʟʟ ᴄᴀᴘꜱ lettering.
  • Pages with technical restrictions preventing "correct" names are displayed using the default name (e.g. https://en.wikipedia.org/wiki/C_Sharp_(programming_language) even if $wgRestrictDisplayTitle is set to false and the displayed page name is overridden with {{DISPLAYTITLE}} ) This applies to pages using characters like square brackets [] and those beginning with an otherwise used prefix such as "Project:"

A Wiki’s users may judge that namespace prefix part of a page name is not necessary under some circumstances, e.g. if all a category’s pages belong to one namespace.

Currently, italics are used to indicate redirects, with no additional explanation.

*Feature summary*

I'd like to see:

  • Book and film titles to appear in italics.
  • Ship names to appear in italics.
  • Trademark names beginning with a lower case letter like eBay to appear properly.
  • bell hooks to be how she wanted to spell her name.
  • ꜱᴍᴀʟʟ ᴄᴀᴘꜱ implementable for linguistics-related titles.
  • Pages with "incorrect" page titles to have their "correct" name shown.
  • The ability for a wiki’s users to decide to remove namespace prefix

And don't forget: At present, redirects are marked by being in italics. This will not be viable after the above changes have been made, so if they are to be marked, they must be marked in another way -- suggest by having (redirect) after them. So, "[President Obama]" (which redirects to "[Barack Obama]" would say "[President Obama] (redirect)" with the link between the square brackets []. Does this need to be a subtask?

How to achieve this (what you would like to be able to do and where):

It might be possible to take the {{DISPLAYTITLE}} value, and display that instead, e.g. {{DISPLAYTITLE:USS ''Enterprise''}} would display as USS <i>Enterprise</i>. This would be OK as a simple solution and perhaps a stopgap one, but there could be problems with this. In particular, there is a one-to-many relationship where there could be a 1-to-1 relationship. It means that same title must be displayed in each category, and this must match the {{DISPLAYTITLE}} value exactly. This is a lack of flexibility that may not be desired. It may be desirable to show different names in different categories. But if it’s easier to implement, this can be done as a first step.

However, for extra flexibility, I'd recommend setting a new default {{DISPLAYCAT}} property and using this so {{DISPLAYCAT:USS ''Enterprise''}} for example.

This probably should have restrictions on it so that it matches the page name, like {{DISPLAYTITLE}} must have $wgRestrictDisplayTitle = false to over-ride.

So default set $wgRestrictDisplayCat = false

The code for this can be copied from that for $wgRestrictDisplayTitle.

For specific categories, currently the sortkey is piped after the category is linked, e.g. [[category:foo|bar]] is sorted under bar. I suggest here there should be a second value, such that for example, [[category:foo|bar|xyzzy]] would be sorted under "bar" but shown as "xyzzy". If two pipes are used, e.g. [[category:foo||xyzzy]] then the default sortkey should be used and the second value, xyzzy overrides the default $displaycat value.

  • Benefits ***

My assessment is that this is the one single biggest display-related issue currently within MediaWiki.

Bugreporter2 raised the priority of this task from Medium to High.Nov 9 2023, 6:49 AM
Bugreporter2 updated the task description. (Show Details)

There is an additional use case for this functionality, not covered in the description and comments above. Namely, an "item" (page) may be known under different names, and those names may context-specific.

In plain language, using some examples:

Consider the following Wikipedia articles:

  1. Chevrolet Aveo (https://en.wikipedia.org/wiki/Chevrolet_Aveo_(T200)) - a car, also marketed as Daewoo Kalos, as well as under various other names/brands
  2. HMT Empire Windrush (https://en.wikipedia.org/wiki/HMT_Empire_Windrush) - a British military transport ship, originally a German passenger ship named Monte Rosa
  3. Courantyne River (https://en.wikipedia.org/wiki/Courantyne_River) - a river in Guyana and Suriname; in Suriname, where Dutch is spoken, it is known under the name Corantijn

It would be reasonable to categorise the "Chevrolet Aveo" page under "Category:Chevrolet vehicles", as well as "Category:Daewoo vehicles". However, doing so would mean that someone looking at "Category:Daewoo vehicles" would see the name "Chevrolet Aveo", rather than "Daewoo Kalos". A workaround, which is currently used on the English Wikipedia, is to instead categorise the "Daewoo Kalos" redirect under "Category:Daewoo vehicles". This solves the original problem, but now someone reading the "Chevrolet Aveo" page cannot access "Category:Daewoo vehicles". Additionally, since the "Chevrolet Aveo" page is not actually categorised under "Category:Daewoo vehicles" it does not come up when querying "Category:Daewoo vehicles" using PetScan or other tools.

Likewise, it would be reasonable to categorise "HMT Empire Windrush" as "Category:Troopships of the United Kingdom", "Category:Passenger ships of Germany" and "Category:Ships operated by Hamburg Süd" (the ship's pre-war operator), etc. The problem is, while the ship was German, it was known as "Monte Rosa", and the name "Empire Windrush" was only adopted when it was taken over by the UK . So, again, someone looking at "Category:Passengers ships of Germany" or "Category:Ships operated by Hamburg Süd" would currently see its post-war English name, which in the context of those categories does not make sense. Here too one could categorise the redirect instead, but then readers of the "HMT Empire Windrush" page would lose access to those categories.

Finally, "Courantyne River" could be categorised as "Category:Rivers in Guyana" and "Category:Rivers in Suriname". It would be reasonable for the latter to use the Dutch form, as that is the name that someone perusing categories about Suirnamese geography is bound to expect.


The above examples hopefully illustrate the need for an option to set a page's display name in a category to something different than the page's actual name. Note that this would need to be category-specific, a global modifier would not address this particular use case.

An example of how this could be implemented from an editor's point of view, using the Chevrolet Aveo example:

The editor would add this on the "Chevrolet Aveo" page:

[[Category:Chevrolet vehicles|Aveo]]
[[Category:Daewoo vehicles|Kalos|display=Daewoo Kalos]]

In "Category:Chevrolet vehicles", the page would be sorted as "Aveo", and displayed as "Chevrolet Aveo", i.e. same as now.
In "Category:Daewoo vehicles", the page would be sorted as "Kalos", and displayed as "Daewoo Kalos".

There is a possible argument whether the original name should also be displayed in some form, e.g. in brackets, perhaps using a smaller font, in order to avoid user confusion when they click on a category item, and a page with a different title opens. For example, it may be preferable, for "Category:Daewoo vehicles" in the above example to display: "Daewoo Kalos (Chevrolet Aveo)"