# Come utilizzare la funzione argomento banner per un gruppo specifico?

**URL:** https://meta.discourse.org/t/how-to-use-banner-topic-feature-for-specific-group/97768
**Category:** Feature
**Created:** [21 Settembre 2018, 1:59pm 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:** 17
**Page:** 1

<div class="post-metadata">

### Author: ![bekircem](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bekircem/32/44582_2.png) [@bekircem](https://meta.discourse.org/u/bekircem)
#### Post date: [21 Settembre 2018, 1:59pm UTC](https://meta.discourse.org/t/how-to-use-banner-topic-feature-for-specific-group/97768/1 "2018-09-21T13:59:28Z")

</div>

Hi,

I want to use the banner topic feature for a specific user group. Only members in that group should be able to see the announcement text. Is this possible?

Thanks.

---

<div class="post-metadata">

### Author: ![awesomerobot](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/awesomerobot/32/142900_2.png) [@awesomerobot](https://meta.discourse.org/u/awesomerobot)
#### Post date: [21 Settembre 2018, 4:15pm UTC](https://meta.discourse.org/t/how-to-use-banner-topic-feature-for-specific-group/97768/2 "2018-09-21T16:15:40Z")

</div>

As long as a user has the specific group set as their primary group, you can do this with CSS.

So for example, my primary group (shown on my user admin page) is team

 ![45%20PM](https://global.discourse-cdn.com/meta/original/3X/8/2/82902389b5d58e8b4a1fa3b96a9a394574547091.png)

This CSS would make it so only people in the group team would see the banner

```CSS
body:not(.team) #banner {
  display: none;
}

```

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.

---

<div class="post-metadata">

### Author: ![bekircem](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bekircem/32/44582_2.png) [@bekircem](https://meta.discourse.org/u/bekircem)
#### Post date: [21 Settembre 2018, 10:34pm UTC](https://meta.discourse.org/t/how-to-use-banner-topic-feature-for-specific-group/97768/3 "2018-09-21T22:34:54Z")

</div>

Hi @awesomerobot

Thank you for reply. What page is this screenshot?

---

<div class="post-metadata">

### Author: ![tshenry](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tshenry/32/119495_2.png) [@tshenry](https://meta.discourse.org/u/tshenry)
#### Post date: [22 Settembre 2018, 12:02am UTC](https://meta.discourse.org/t/how-to-use-banner-topic-feature-for-specific-group/97768/4 "2018-09-22T00:02:07Z")

</div>

His screenshot was taken from the user admin page under the **Groups** section.

If you go to a user’s public profile as an administrator, you should see the ![admin](https://global.discourse-cdn.com/meta/original/3X/7/3/7395ca2cff44d49e202515b0561a9effb3d7301f.png) button near the top right. Scroll down a bit after you have selected that button. You should see the “ **Groups** ” section and the options in that screenshot.

You can also set up a group so that it will automatically be set as the primary group of all its members. If you go this route, just be aware this automatic feature might change any existing primary group settings of its members.

---

<div class="post-metadata">

### Author: ![bekircem](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bekircem/32/44582_2.png) [@bekircem](https://meta.discourse.org/u/bekircem)
#### Post date: [22 Settembre 2018, 5:16am UTC](https://meta.discourse.org/t/how-to-use-banner-topic-feature-for-specific-group/97768/5 "2018-09-22T05:16:03Z")

</div>

Hi @tshenry,

Thanks for the reply. Does it also apply to new registrants automatically?

---

<div class="post-metadata">

### Author: ![tshenry](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tshenry/32/119495_2.png) [@tshenry](https://meta.discourse.org/u/tshenry)
#### Post date: [22 Settembre 2018, 9:35am UTC](https://meta.discourse.org/t/how-to-use-banner-topic-feature-for-specific-group/97768/6 "2018-09-22T09:35:29Z")

</div>

> [@bekircem](#):
>
> Does it also apply to new registrants automatically?

Yes if you check the “[\*]Automatically set as primary group” option in the group management settings, any members added to that group will have it automatically set as their primary group.

---

<div class="post-metadata">

### Author: ![bekircem](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bekircem/32/44582_2.png) [@bekircem](https://meta.discourse.org/u/bekircem)
#### Post date: [22 Settembre 2018, 12:33pm UTC](https://meta.discourse.org/t/how-to-use-banner-topic-feature-for-specific-group/97768/7 "2018-09-22T12:33:27Z")

</div>

I created “specificgroup” user group. I added a user to this group. Also, i added this code to CSS.

```
body:not(.specificgroup) #banner {
  display: none;
}

```

But it is don’t work for me. Banner does not appear for the specificgroup member group.

---

<div class="post-metadata">

### Author: ![tshenry](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tshenry/32/119495_2.png) [@tshenry](https://meta.discourse.org/u/tshenry)
#### Post date: [22 Settembre 2018, 1:08pm UTC](https://meta.discourse.org/t/how-to-use-banner-topic-feature-for-specific-group/97768/8 "2018-09-22T13:08:43Z")

</div>

Try putting `primary-group-` before your group’s name:

```plaintext
body:not(.primary-group-YOUR_GROUP_NAME) #banner {
  display: none;
}

```

---

<div class="post-metadata">

### Author: ![bekircem](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bekircem/32/44582_2.png) [@bekircem](https://meta.discourse.org/u/bekircem)
#### Post date: [22 Settembre 2018, 4:25pm UTC](https://meta.discourse.org/t/how-to-use-banner-topic-feature-for-specific-group/97768/9 "2018-09-22T16:25:54Z")

</div>

Yes, it works! Thanks for that great solution.

I have one more question: Is it possible to use with different banners for more than one group?

Thanks everyone for participation! 🙂

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [22 Settembre 2018, 11:00pm UTC](https://meta.discourse.org/t/how-to-use-banner-topic-feature-for-specific-group/97768/10 "2018-09-22T23:00:21Z")

</div>

There can be only one banner topic any any given time, and there is no such thing as a category banner topic. Though it is relatively easy to “not display” it for certain categories / groups, it would be more involved to “display different banner topics” when there can be only one. I think the only way to have something like “category banners” would be with a plugin.

---

<div class="post-metadata">

### Author: ![tshenry](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tshenry/32/119495_2.png) [@tshenry](https://meta.discourse.org/u/tshenry)
#### Post date: [22 Settembre 2018, 11:47pm 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.

---

<div class="post-metadata">

### Author: ![bekircem](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bekircem/32/44582_2.png) [@bekircem](https://meta.discourse.org/u/bekircem)
#### Post date: [2 Ottobre 2018, 8:40pm UTC](https://meta.discourse.org/t/how-to-use-banner-topic-feature-for-specific-group/97768/12 "2018-10-02T20:40:50Z")

</div>

Hi, thanks for great the documentation. I tested in my local development environment. But it seems banner’s seems to all groups. Did I get something wrong?

 ![image](https://global.discourse-cdn.com/meta/original/3X/a/3/a35ee2e4d66f3cc40a477267b30bbf5752d1daf0.png)

css:

```css
// Hide all by default
#banner [data-theme-group] {
    display: none;
}

// Show specific content for a specific group
body.primary-group-team #banner [data-theme-group="team"],
body.primary-group-specificgroup #banner [data-theme-group="specificgroup"] {
    display: block;
}

```

after header:

```html
<div data-theme-group="team">
  # Banner 1
</div>
<div data-theme-group="specificgroup">
  # Banner 2
</div>

```

edit: oh, i got it, it is not related to after header. i am trying now. 🙂

---

<div class="post-metadata">

### Author: ![bekircem](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bekircem/32/44582_2.png) [@bekircem](https://meta.discourse.org/u/bekircem)
#### Post date: [2 Ottobre 2018, 9:19pm UTC](https://meta.discourse.org/t/how-to-use-banner-topic-feature-for-specific-group/97768/13 "2018-10-02T21:19:39Z")

</div>

Ok, it works but there is a problem. Empty banner box seems to anonymous users. And suggestion for that?

 ![image](https://global.discourse-cdn.com/meta/original/3X/c/a/cad6252a09ec718343dbd170f151bc9d1e409396.png)

> [@tshenry](#):
>
> This can also be used to control different banner content for different categories with a little alteration to the code.

Can you share example of code? Thanks 🙂

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [2 Ottobre 2018, 11:15pm UTC](https://meta.discourse.org/t/how-to-use-banner-topic-feature-for-specific-group/97768/14 "2018-10-02T23:15:44Z")

</div>

What is the closest parent element that contains the banner? That’s the element you need to target for the display none rule.

---

<div class="post-metadata">

### Author: ![tshenry](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tshenry/32/119495_2.png) [@tshenry](https://meta.discourse.org/u/tshenry)
#### Post date: [2 Ottobre 2018, 11:45pm UTC](https://meta.discourse.org/t/how-to-use-banner-topic-feature-for-specific-group/97768/15 "2018-10-02T23:45:38Z")

</div>

> [@bekircem](#):
>
> Empty banner box seems to anonymous users. And suggestion for that?

To hide the banner completely for anon, you need to add the following to your CSS:

```plaintext
.anon #banner {
    display: none;
}

```

> [@bekircem](#):
>
> Can you share example of code? Thanks 🙂

I don’t have it written out and ready, unfortunately. I’ll write it up and post it when I get chance.

---

<div class="post-metadata">

### Author: ![bekircem](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bekircem/32/44582_2.png) [@bekircem](https://meta.discourse.org/u/bekircem)
#### Post date: [3 Ottobre 2018, 6:09am UTC](https://meta.discourse.org/t/how-to-use-banner-topic-feature-for-specific-group/97768/16 "2018-10-03T06:09:37Z")

</div>

> [@tshenry](#):
>
> To hide the banner completely for anon, you need to add the following to your CSS:
> 
> ```plaintext
> .anon #banner {
> display: none;
> }
> 
> ```

We hide empty banners to anonymous users but empty banners seems by other group users too. How i fix that? Thanks.

---

<div class="post-metadata">

### Author: ![tshenry](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tshenry/32/119495_2.png) [@tshenry](https://meta.discourse.org/u/tshenry)
#### Post date: [4 Ottobre 2018, 9:36am UTC](https://meta.discourse.org/t/how-to-use-banner-topic-feature-for-specific-group/97768/17 "2018-10-04T09:36:21Z")

</div>

You will need to replace any of the CSS posted earlier with the following. This will hide the entire banner for anons and any users not part of a group that has an associated banner. Once again replace `GROUP_ONE`, `GROUP_TWO`, etc with the relevant group names.

```plaintext
body {
    // Hide the banner and all group-specific content by default
    #banner,
    #banner [data-theme-group] {
            display: none;
    }
    
    // Display the banner for the following groups only
    &.primary-group-GROUP_ONE {
        #banner,
        #banner [data-theme-group="GROUP_ONE"] {
            display: block;
        }
    }
    &.primary-group-GROUP_TWO {
        #banner,
        #banner [data-theme-group="GROUP_TWO"] {
            display: block;
        }
    }
    &.primary-group-GROUP_THREE {
        #banner,
        #banner [data-theme-group="GROUP_THREE"] {
            display: block;
        }
    }
}

```
