Page MenuHomePhabricator

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

Description

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.


Version: unspecified
Severity: enhancement

Details

Reference
bz29975

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.