# 如何使用横幅主题功能针对特定群组？

**URL:** <https://meta.discourse.org/t/how-to-use-banner-topic-feature-for-specific-group/97768>\
**Category:** Feature\
**Created:** [2018 年9 月 21 日 13:59 UTC](https://meta.discourse.org/t/how-to-use-banner-topic-feature-for-specific-group/97768 "2018-09-21T13:59:28Z")\
**Posts on this page:** 1\
**Showing post:** 11

<div class="post-metadata">

作者： ![tshenry](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tshenry/32/119495_2.png) [@tshenry](https://meta.discourse.org/u/tshenry)\
发布日期： [2018 年9 月 22 日 23:47 UTC](https://meta.discourse.org/t/how-to-use-banner-topic-feature-for-specific-group/97768/11 "2018-09-22T23:47:13Z")

</div>

I think I’ve got a solution for you, but there will be several pieces of the puzzle you will need to fill in yourself:

Go to the topic you are using for your banner topic. What you will need to do is create sections in the post that are specific for each group. So for example:

```
<div data-theme-group="GROUP_ONE">

# Banner 1

</div>

<div data-theme-group="GROUP_TWO">

# Banner 2

</div>

<div data-theme-group="GROUP_THREE">

# Banner 3

</div>

```

Anything you place within the `<div>`s will be specific to the group you are targeting. Anything outside of the `<div>`'s will be shown to everyone. We’ll use CSS to control what is seen given a user’s group:

```plaintext
// Hide all by default
#banner [data-theme-group] {
    display: none;
}
// Show specific content for a specific group
body.primary-group-GROUP_ONE #banner [data-theme-group="GROUP_ONE"],
body.primary-group-GROUP_TWO #banner [data-theme-group="GROUP_TWO"],
body.primary-group-GROUP_THREE #banner [data-theme-group="GROUP_THREE"] {
    display: block;
}

```

Let me know if you need me to clarify anything. There may be a cleaner implementation of this, but it’s what I could come up with quickly. This can also be used to control different banner content for different categories with a little alteration to the code.

Also just a reminder that this still applies:

> [@awesomerobot](#):
>
> Just keep in mind that this uses CSS to hide the banner for everyone else, so someone in another group could potentially see the banner if they were inspecting the page and looking for it.

---

_[View the full topic](https://meta.discourse.org/t/how-to-use-banner-topic-feature-for-specific-group/97768)._
