Site logo

Archived topic

GPP 2.0 Feature Request - Ability to assign custom class to content template

5 replies · Started by George on April 12, 2021

Viewing posts 1–6 of 6

It would be good if we were able to assign a custom class to the actual content template itself apart from a GB container element, for instance.

Hi there,

What element would the class be applied to? Would it be the body or the theme element wrapper such as the <article> element in an archive ?

Hi David. It would be the element outside <article>, in this case, the element that has a class of generate-columns-container which is the entire content template. Sometimes, I use the content element conditionally for multiple pages but I want to be able to style that container differently for various pages or archives. I could use CSS selectors for all those pages but it's not so maintainable. If I had an outer class, I could just use that particular class for the whole container and target that class in one CSS selector. I hope, I make sense?

Might be handier to output a class to the <body> tag - its an easier element to filter and can be cascaded down for example:

body.has-custom-element-class

which could then be used to target any element on the page eg.

body.has-custom-element-class .generate-columns-container or body.has-custom-element-class .post

I'll nag Tom as we looked at this as an option for other Elements - not sure what the reluctance is lol

Yeah, that would work, too, I guess.

Thanks, David!

Actually, the solution you provided will need multiple classes for various pages. My solution to provide a class for the actual template would reduce the number of selectors since that class could be reused for all custom layouts related to that template if you know what I mean.

Edit: No, I see what you mean, the body class would be a custom one taken from the template itself, I stand corrected!

This archived topic is closed to new replies.