XF 2.3 Help needed with promotions and user banners please

Alvin63

Well-known member
Ok I've read around a lot about this, and I'm part there but. Basically I don't want anyone to have more than two banners but I want to add a "Donator" banner. I have banner stacking turned off as don't want 3 banners.

Additional role banners had been set up manually just adding someone - because everyone only had one banner. But I want a lot more people to have two banners.

So I've basically deleted a promotion I had set up, deleted three groups I had set up, and started again trying to do the "Is not a member of" thing in promotions, so the banners get promoted rather than stacking.

I've achieved it from the initial banner to the second one, via promotion. So from Registered to Group 1. Banners changing for Group 1,

I then set up group 2 - which is just for one member with a specific role. Achieved that by selecting "Is a member of Registered and Group 1" - is NOT a member of Group 2 (specific role). And a higher priority number obviously.

So all good until I started trying to do Group 3 - which is a different specific role for two members. Every time I try to set that up it reverts the Group 1 member back to Registered (despite group 3 having a higher priority setting than group 2 and so on).

So assume it's something in the "IS a member of" and is not a member of - Initially I set it up the same as group 2 "IS a member of Registered and Group 1" "IS not a member of Group 3 specific role, I've tried a few permutations now and cannot get both Group 2 and Group 3 to display the correct banners.


Additionally, setting up group 3 has reverted admin and a few others randomly back to new member (even though the only banners set are registered (new member), group 1 and group 2.

It's chaotic, And I started from scratch! I've spent hours on this and getting nowhere. The only reason I don't want 3 banners for people is - it doesn't look good on mobile.

The easy solution perhaps would be to go back to what I was doing before starting all this, and have some kind of code to just "remove" the member banner from anyone who has a second banner. Is that possible?
 
Last edited:
I've thought of one option maybe. Keep banner stacking off. Forget the promotions. One banner each as before. But for the extra donator banner, edit the staff banner wording to donator and use that (and remove the staff online widget). ie just add donators as staff (but it wouldn't say staff it would say donator).

Any thoughts on that? Has anyone else done that?
 
So i've givin this a bit of thought, can you just leave Allow banner stacking ticked, and set up a javascript that only displays a max of two banners?
Then just organise the group into the 2 banners you want showing as high priotiy. or perhaps could you not just disable all the banners except the ones you want visible?


I did something like this when I wanted conditional banners
CSS:
// Staff Banner Effects
.userBanner.userBanner--syl_staff_administrator:before {
      .m-faBase();
      .m-faContent(@fa-var-balance-scale);
    margin-right: 2px
}

.userBanner.userBanner--syl_staff_moderator:before {
      .m-faBase();
      .m-faContent(@fa-var-shield-alt);
    margin-right: 2px
}

.userBanner--syl_staff_administrator + .userBanner--syl_staff_moderator,
.userBanner--syl_staff_moderator + .userBanner--syl_staff_administrator {
  display: none;
}
 
Thank you very much! Those are great tips :-) I got in such a muddle with it. I ended up leaving banner stacking off. Not using the staff banner for admin (adding a shield for admin as you have there), removing the "Staff online" widget. Editing the text of the staff banner wording for the extra banner I want to manually give to some people (in phrases). Which means I have to manually tick or untick them from the banner each time so need to keep a list of who has it. I know nothing about coding - some of what you have above, I have, to add font awesome icons.

And yes I was wondering if there was a way of only allowing a max of two banners, Because I don't want everyone having the registered banner when they have their own banner.

That is really helpful and some extra things there I could try :-) Also looking into adding an image instead of a banner .............

It would be ok having 3 banners if that displayed well on mobile. If the banner names are short enough, it's ok and 3 sit next to each other on the same line on mobile.

Basically, I just wanted to add a "supporter" banner to some members.
 
Last edited:
Thank you very much! Those are great tips :-) I got in such a muddle with it. I ended up leaving banner stacking off. Not using the staff banner for admin (adding a shield for admin as you have there), removing the "Staff online" widget. Editing the text of the staff banner wording for the extra banner I want to manually give to some people (in phrases). Which means I have to manually tick or untick them from the banner each time so need to keep a list of who has it. I know nothing about coding - some of what you have above, I have, to add font awesome icons.

And yes I was wondering if there was a way of only allowing a max of two banners, Because I don't want everyone having the registered banner when they have their own banner.

That is really helpful and some extra things there I could try :-) Also looking into adding an image instead of a banner .............

It would be ok having 3 banners if that displayed well on mobile. If the banner names are short enough, it's ok and 3 sit next to each other on the same line on mobile.

Basically, I just wanted to add a "supporter" banner to some members.
I decided to get a little more creative :)
I assume the issues only with the posts part of the site?

So in a thread when a post is made under the avatar, you have the banners visible. We can modify that macro using this template post_macros
If we then add:
HTML:
<xf:js>
document.querySelectorAll('.message-userDetails').forEach(container => {
  const banners = container.querySelectorAll('.userBanner.message-userBanner');
  banners.forEach(banner => {
    // Check if the banner contains one of the allowed classes
    if (
      banner.classList.contains('userBanner--syl_pro_he_him') ||
      banner.classList.contains('userBanner--syl_pro_fae_faer')
    ) {
      banner.style.display = ''; // show
    } else {
      banner.style.display = 'none'; // hide
    }
  });
});
</xf:js>

into the macro we can control which banners we'd like to see. So for example I'm only showing banners that contain this userBanner--syl_pro_fae_faer or userBanner--syl_pro_he_him.

This turns this thread
1754413916008.webp

into this
1754413945362.webp

Without us removing banners. The banners will still appear on the users profile. They just won't appear in the threads.
 
Back
Top Bottom