Add class="ns-talk" / "ns-subject" to <body>
Closed, ResolvedPublic


Author: happy_melon

Per DavidGothberg's suggestion at it would be sensible to add another class to the attributes of <body> in all pages: "ns-talk" for all odd namespaces, and something like "ns-subject" for all even namespaces. I expect this would be trivial in both performance and coding time.

Version: unspecified
Severity: enhancement

bzimport added projects: MediaWiki-Parser, Easy.Via ConduitNov 21 2014, 10:21 PM
bzimport added a subscriber: Unknown Object (MLST).
bzimport set Reference to bz15079.
bzimport created this task.Via LegacyAug 7 2008, 9:18 PM
demon added a comment.Via ConduitAug 7 2008, 10:47 PM

I suggest WONTFIX. The rationale for adding this is rather limited, as .ns-1, .ns-3, etc is perfectly valid CSS. Unlike bug 15052 which is at least arguably useful. The body class has _quite_ a few classes on it already, and tacking another one (esp. one with such limited actual use) seems like a waste.

The data is already there, use it.

brion added a comment.Via ConduitAug 8 2008, 12:11 AM

The set of namespaces is potentially open-ended; new custom (and new standard!) namespaces could be added at any time, requiring an infinite list of all odd numbers to cover your bases. ;)

Much simpler to have a distinct marker.

bzimport added a comment.Via ConduitAug 8 2008, 12:35 AM

ayg wrote:

Not infinite, just 2^30 or so. ;) I guess it's simpler to have this if a lot of user CSS relies on it, since that can't be so easily tracked down and updated, but it seems excessive. Then again, there's technically no cost to having loads of extra classes, I suppose.

bzimport added a comment.Via ConduitAug 8 2008, 1:34 AM

alexsm333 wrote:

Note that the existence of multipurpose ns-4 "Project" namespace (used for discussions, guides, essays, etc) makes the "ns-talk" proposal a lot less useful.

bzimport added a comment.Via ConduitAug 8 2008, 9:24 AM

happy_melon wrote:

I don't remember putting that in the user manual... :D

It's only tradition that results in multipurpose use of ns-4; it's rather counterintuitive given the rigidity with which we control the use of other namespaces. In an ideal world ns-4 and ns-5 would be as clearly delimited as the others. But that's besides the point.

For a real example, I have an inkling that what DavidGothberg wants to do is unite all the messagebox templates on ([[Template:Ambox]], [[Template:Imbox]], [[Template:Tmbox]], etc), and present one template with a display switched by CSS, not by parser functions. [[Template:Tmbox]] is intended to be used in *all* our even namespaces (for reference, [[Template:Ombox]] is the style prescribed for ns-4). This would instantly give namespace-switching capabilities to all our messageboxes, which is something we've been struggling to do without creating a monster of a metatemplate. So in this example, the presence of the "multipurpose" ns-4 is of no relevance.

bzimport added a comment.Via ConduitAug 8 2008, 10:20 AM

happy_melon wrote:

If anyone does want to do this, I think it's as easy as adding:

($wgTitle->getNamespace() % 2 ? "ns-talk" : "ns-subject").' '.

to the end of line 549 in /trunk/phase3/includes/Skin.php (one day I'm going to have to learn how to write proper patches!)

bzimport added a comment.Via ConduitAug 8 2008, 1:43 PM

ayg wrote:

MWNamespace::isTalk( $wgTitle->getNamespace ) ? 'ns-talk' : 'ns-subject' would be more correct, although they might be functionally similar at the moment. Anyway, yes, it's trivial to do, the question is whether we want it.

brion added a comment.Via ConduitAug 8 2008, 11:35 PM

$wgTitle->isTalkPage() would be even better. :)

And yes, we want it. There's no other reliable way to apply CSS to all talk pages or all subject pages. (Listing every possible talk namespace is not an option, as that's an open-ended set.)

bzimport added a comment.Via ConduitAug 9 2008, 6:23 AM

sxwiki wrote:

Patch to add ns-talk or ns-subject to body

This patch should do what you guys want. Ended up having to modify a couple other files as well to get it to appear on all skins.

Attached: skin.patch

bzimport added a comment.Via ConduitAug 10 2008, 8:30 AM

sxwiki wrote:

Fixed in r39054 .

Add Comment