CSS class on Body tag to distinguish homepage / non-category page


(Charles Walter) #1

I had mentioned this in another topic, but thought I’d be more direct :blush:

Could a class be added to the body tag of the homepage (and perhaps to all non-category pages)? I couldnt figure out how to target CSS only to be applied to the homepage or non category pages

ie BODY class=latesthome global

(If no category identified, the global class gets added)

Its particularly useful for backgrounds. Categories of course have the baked in background feature, but to apply backgrounds for other screens, we depend on css. It also means for inner pages, we are loading our global background unnecessarily.

Perhaps there’s already some way of achieving what I’m describing, in a cleaner way?


(Jeff Atwood) #2

I believe @techapj worked on something related to this recently.


(Arpit Jalan) #3

This was recently done via:

Currently there is no identifier (unique class) for /latest, /new, /unread & /top pages. I will add that and notify here.


(Charles Walter) #4

Very cool @techAPJ. What do you think of the suggesting of adding a catch all “global” class as well, when there is no category defined. This can be an easy way to set a background (for example) for all pages that don’t belong to a category, without having to identify every single one .


(Mittineague) #5

I don’t think there would be that many of them where using a comma separated list would be that much trouble.

But a “global” class would be easier.

If it’s going to be done I guess now while that area of code is being worked on would be the opportune time to do it.

Think as I might, ATM the best I can come up with as a descriptive value is “non-category”. It just feels to me that there should be something, anything better than that, but I got nothing.


(Charles Walter) #6

Thx for considering the suggestion. Other ideas for the class name. I am ultimately indifferent :wink:
no-category
category0
general
site-main
core


(Arpit Jalan) #7

Added navigation-topics class to above mentioned pages (via this commit).

This will be tricky to implement. The better solution IMO is to assign a unique class to a page (or set of pages).


(Charles Walter) #8

Thx @techAPJ!

I mentioned the no-category class, thinking that the DFP plugin has a unique variable of 0 that it uses for all pages that don’t have an associated category. So I assumed that the same logic could be applied.