Users are discussing whether it’s possible to display different Banner Topics based on user group membership in Discourse. joebuhlig initially asked if banners could be targeted to specific groups — such as showing one banner to anonymous users and another to logged-in users not in a specific group — without building a full plugin. sam expressed concern about admin confusion and suggested a CSS-based workaround: using one large banner and hiding parts via CSS selectors. joebuhlig considered this but noted the difficulty of targeting elements without CSS classes or IDs, and cpradio confirmed no high-level group-specific classes exist on the body or html tags. sam reiterated that nth-child selectors would be necessary, or whitelisting content for everyone. joebuhlig planned to add group names to the body or html classes and target banners via nth selectors, but later reported switching to a custom theme that injects group-specific header content directly. Later, jrgong revived the thread seeking a solution for client-only banners, noting CSS hiding is insufficient since content remains visible via Inspect Element. Heliosurge suggested the Discourse Category Home plugin as a possible solution or starting point for a feature request.
I have a situation where I want to display different Banner Topics dependent on the users group membership. Namely, I’d like to show one banner if a user isn’t logged in and a different one if they are but aren’t a part of a specific group.
I could likely set up categories to target the two sectors but is it possible to target users with specific Banner Topics? I’d rather not build a customization to do it but I’m also not tossing that idea.
I worry that this would be extremely confusing from an admin perspective. I would need a completely new UI to support configuring this without enormous amounts of admin confusion.
One hacky possibility with minimal change would be to have one big banner for everyone and then use CSS to hide bits.
That was my concern as well. It would be a pain to manage as an admin. I just wondered if it was even possible.
I may give this a try as it seems much quicker and easier than building the full customization via plugin. But last I knew, we couldn’t apply CSS classes or ids via the composer. Outside of using an nth-selector, is there another way to do this?
I know you can do it for anon versus logged in, but I’m not sure you can achieve it via Groups. As to my knowledge there is no high-level (on the html or body tag) CSS class denoting the group the user is a part of.
Yeah it is not going to be easy, nth selector is what you are going to be forced to use. Otherwise you are going to be forced to whitelist stuff for everyone.
Thanks, @sam and @cpradio. I think my plan of attack will be to add the group names to the body/html classes and follow down to the nth div of the banner topic.