Skip to content

Custom badges

Solved Customisation
103 4 25.6k 2
  • What is the best way/plugin to have custom badges like the twitter blue check mark?

    blue verified.png

    @phenomlab I see you have these colorful onesโ€ฆ which are quite close:

    Screen Shot 2022-11-16 at 11.54.02.png

  • What is the best way/plugin to have custom badges like the twitter blue check mark?

    blue verified.png

    @phenomlab I see you have these colorful onesโ€ฆ which are quite close:

    Screen Shot 2022-11-16 at 11.54.02.png

    @crazycells I expect the quickest way to do this will be using groups. I do something similar - I have a โ€œverifiedโ€ group, and once a new member starts engaging, they are added here so I know they are actually who they say they are.

    In terms of CSS, I use

    .group-label {
        margin-right: -12px;
        margin-top: 1px;
        width: 22px;
        height: 22px;
        border-radius: 11px;
        line-height: 21px;
        display: inline-block;
        vertical-align: middle;
        text-align: center;
        overflow: hidden;
    }
    small.label.group-label.inline-block i {
        margin-top: 1px;
        margin-left: 0px;
        vertical-align: middle;
        display: flex;
        justify-content: center;
    }
    

    It wouldnโ€™t take much effort to get these to look like the blue Twitter check mark.

    As a point of interest (and convenience), Font Awesome has something extremely close

    59db89f5-2c7a-4052-8106-31264d7fa05f-image.png

    Sadly, itโ€™s part of the PRO set, so unless you have a license, itโ€™s not within reach

    1b9bde0a-1b83-41e5-a0ba-5b1131a68332-image.png

    However, I have a license, and could easily make a PNG out of this without too much effort for those who donโ€™t (not cheap AT USD 99.00 per year).

    If youโ€™d rather not use groups, you can use native CSS, but you are limited in terms of targets. For example, the author badge is easy because you can simply target the [itemprop="author"] class. However, posts from other users will not have this, and thatโ€™s where the groups come to the rescue.

    If any interest, I can put some code together to show you how this would work.

  • @crazycells I expect the quickest way to do this will be using groups. I do something similar - I have a โ€œverifiedโ€ group, and once a new member starts engaging, they are added here so I know they are actually who they say they are.

    In terms of CSS, I use

    .group-label {
        margin-right: -12px;
        margin-top: 1px;
        width: 22px;
        height: 22px;
        border-radius: 11px;
        line-height: 21px;
        display: inline-block;
        vertical-align: middle;
        text-align: center;
        overflow: hidden;
    }
    small.label.group-label.inline-block i {
        margin-top: 1px;
        margin-left: 0px;
        vertical-align: middle;
        display: flex;
        justify-content: center;
    }
    

    It wouldnโ€™t take much effort to get these to look like the blue Twitter check mark.

    As a point of interest (and convenience), Font Awesome has something extremely close

    59db89f5-2c7a-4052-8106-31264d7fa05f-image.png

    Sadly, itโ€™s part of the PRO set, so unless you have a license, itโ€™s not within reach

    1b9bde0a-1b83-41e5-a0ba-5b1131a68332-image.png

    However, I have a license, and could easily make a PNG out of this without too much effort for those who donโ€™t (not cheap AT USD 99.00 per year).

    If youโ€™d rather not use groups, you can use native CSS, but you are limited in terms of targets. For example, the author badge is easy because you can simply target the [itemprop="author"] class. However, posts from other users will not have this, and thatโ€™s where the groups come to the rescue.

    If any interest, I can put some code together to show you how this would work.

    @phenomlab yes, actually, I am using the groups for badges alreadyโ€ฆ it is very similar to the โ€œranksโ€ you are using here, but rather than words, we went with โ€œstarsโ€ , in our forum depending on your post count or upvote count you can get from 1 to 5 starsโ€ฆ and getting 1 star is quite work, because it requires minimum 500 posts or upvotesโ€ฆ for exampleโ€ฆ
    we have 5 stars max.
    Screen Shot 2022-11-16 at 14.29.38.png
    or another member with 2 starsโ€ฆ
    Screen Shot 2022-11-16 at 14.29.54.png

    I am still not clear on how to create this badge, but let me first try with CSS codes. I think something similar to a blue check should be enough for us. Unfortunately, we are using the free version of font awesomeโ€ฆ

    I will get back to you after trying.

  • @phenomlab yes, actually, I am using the groups for badges alreadyโ€ฆ it is very similar to the โ€œranksโ€ you are using here, but rather than words, we went with โ€œstarsโ€ , in our forum depending on your post count or upvote count you can get from 1 to 5 starsโ€ฆ and getting 1 star is quite work, because it requires minimum 500 posts or upvotesโ€ฆ for exampleโ€ฆ
    we have 5 stars max.
    Screen Shot 2022-11-16 at 14.29.38.png
    or another member with 2 starsโ€ฆ
    Screen Shot 2022-11-16 at 14.29.54.png

    I am still not clear on how to create this badge, but let me first try with CSS codes. I think something similar to a blue check should be enough for us. Unfortunately, we are using the free version of font awesomeโ€ฆ

    I will get back to you after trying.

    @crazycells no issues. Keep me posted. As a side note, would the stars on your forum look better with a transparent background rather than the blue?

  • @crazycells no issues. Keep me posted. As a side note, would the stars on your forum look better with a transparent background rather than the blue?

    @phenomlab said in Custom badges:

    @crazycells no issues. Keep me posted. As a side note, would the stars on your forum look better with a transparent background rather than the blue?

    this color comes from our logoโ€ฆ we have two colors in the logo, blue and redโ€ฆ so we are using this color and red color for all the badges, so it looks compatible with our general theme and most importantly it makes easier to spot the โ€œstarsโ€โ€ฆ this is kind of to encourage more people to contribute and get starsโ€ฆ

    gamification works ๐Ÿ™‚

  • @phenomlab said in Custom badges:

    @crazycells no issues. Keep me posted. As a side note, would the stars on your forum look better with a transparent background rather than the blue?

    this color comes from our logoโ€ฆ we have two colors in the logo, blue and redโ€ฆ so we are using this color and red color for all the badges, so it looks compatible with our general theme and most importantly it makes easier to spot the โ€œstarsโ€โ€ฆ this is kind of to encourage more people to contribute and get starsโ€ฆ

    gamification works ๐Ÿ™‚

    @crazycells makes sense !

  • @crazycells I expect the quickest way to do this will be using groups. I do something similar - I have a โ€œverifiedโ€ group, and once a new member starts engaging, they are added here so I know they are actually who they say they are.

    In terms of CSS, I use

    .group-label {
        margin-right: -12px;
        margin-top: 1px;
        width: 22px;
        height: 22px;
        border-radius: 11px;
        line-height: 21px;
        display: inline-block;
        vertical-align: middle;
        text-align: center;
        overflow: hidden;
    }
    small.label.group-label.inline-block i {
        margin-top: 1px;
        margin-left: 0px;
        vertical-align: middle;
        display: flex;
        justify-content: center;
    }
    

    It wouldnโ€™t take much effort to get these to look like the blue Twitter check mark.

    As a point of interest (and convenience), Font Awesome has something extremely close

    59db89f5-2c7a-4052-8106-31264d7fa05f-image.png

    Sadly, itโ€™s part of the PRO set, so unless you have a license, itโ€™s not within reach

    1b9bde0a-1b83-41e5-a0ba-5b1131a68332-image.png

    However, I have a license, and could easily make a PNG out of this without too much effort for those who donโ€™t (not cheap AT USD 99.00 per year).

    If youโ€™d rather not use groups, you can use native CSS, but you are limited in terms of targets. For example, the author badge is easy because you can simply target the [itemprop="author"] class. However, posts from other users will not have this, and thatโ€™s where the groups come to the rescue.

    If any interest, I can put some code together to show you how this would work.

    @phenomlab how can I target one specific group with CSS codes?
    With this CSS, other group badges turn into rounds as well.

  • @phenomlab how can I target one specific group with CSS codes?
    With this CSS, other group badges turn into rounds as well.

    Screen Shot 2022-11-17 at 13.28.34.png

    actually, it looks very good (quite acceptable for our case ๐Ÿ™‚ ), thanks for the CSS codes; however CSS codes affect other group badges tooโ€ฆ

    group name: verified

    how can I restrict CSS codes to this group? I checked the inspector, I can only see group links, but not specific namesโ€ฆ

  • @crazycells I expect the quickest way to do this will be using groups. I do something similar - I have a โ€œverifiedโ€ group, and once a new member starts engaging, they are added here so I know they are actually who they say they are.

    In terms of CSS, I use

    .group-label {
        margin-right: -12px;
        margin-top: 1px;
        width: 22px;
        height: 22px;
        border-radius: 11px;
        line-height: 21px;
        display: inline-block;
        vertical-align: middle;
        text-align: center;
        overflow: hidden;
    }
    small.label.group-label.inline-block i {
        margin-top: 1px;
        margin-left: 0px;
        vertical-align: middle;
        display: flex;
        justify-content: center;
    }
    

    It wouldnโ€™t take much effort to get these to look like the blue Twitter check mark.

    As a point of interest (and convenience), Font Awesome has something extremely close

    59db89f5-2c7a-4052-8106-31264d7fa05f-image.png

    Sadly, itโ€™s part of the PRO set, so unless you have a license, itโ€™s not within reach

    1b9bde0a-1b83-41e5-a0ba-5b1131a68332-image.png

    However, I have a license, and could easily make a PNG out of this without too much effort for those who donโ€™t (not cheap AT USD 99.00 per year).

    If youโ€™d rather not use groups, you can use native CSS, but you are limited in terms of targets. For example, the author badge is easy because you can simply target the [itemprop="author"] class. However, posts from other users will not have this, and thatโ€™s where the groups come to the rescue.

    If any interest, I can put some code together to show you how this would work.

    @phenomlab

    Thank you very much for the code.

    In my case, I would like to display the group labels after the user level label because as it is itโ€™s not very nice

    Same for Author Badge

    6e43f17a-ed43-451c-b68f-4f3a5bc71078-image.png

  • @phenomlab

    Thank you very much for the code.

    In my case, I would like to display the group labels after the user level label because as it is itโ€™s not very nice

    Same for Author Badge

    6e43f17a-ed43-451c-b68f-4f3a5bc71078-image.png

    @DownPW and @crazycells could you let me have URLโ€™s where I can see examples of what youโ€™ve posted?

  • @DownPW and @crazycells could you let me have URLโ€™s where I can see examples of what youโ€™ve posted?

    @phenomlab Prod server

  • @DownPW Something like this?

    879aa7c9-5e97-4c5f-bb82-014524653254-image.png

    CSS modifications

    .topic-owner-post [itemprop="author"] {
        float: left;
    }
    // Add these to (or edit) the existing classes you have
    .user-level-topic {
        float: none;
    }
    .group-label {
        margin-top: -1px;
    }
    .topic-owner-post [itemprop="author"]:after {
        margin-top: 1px;
        height: 18px;
    }
    
  • @DownPW Something like this?

    879aa7c9-5e97-4c5f-bb82-014524653254-image.png

    CSS modifications

    .topic-owner-post [itemprop="author"] {
        float: left;
    }
    // Add these to (or edit) the existing classes you have
    .user-level-topic {
        float: none;
    }
    .group-label {
        margin-top: -1px;
    }
    .topic-owner-post [itemprop="author"]:after {
        margin-top: 1px;
        height: 18px;
    }
    

    @phenomlab

    yep but I have not the same result as you with this code :

    24bc3b0a-29a3-45f7-8e6b-bc72f6248bda-image.png

    The username is after the userlevel badge ๐Ÿ˜’

  • @phenomlab

    yep but I have not the same result as you with this code :

    24bc3b0a-29a3-45f7-8e6b-bc72f6248bda-image.png

    The username is after the userlevel badge ๐Ÿ˜’

    @DownPW Can you put the code back to what I provided? I see you are making changes

  • @DownPW Can you put the code back to what I provided? I see you are making changes

  • @DownPW Thanks. Seems I forgot this

    [itemprop="author"] {
        float: left;
    }
    

    And this which will fix the overlap on the reply label

    .topic [component="post/parent"] {
        margin-left: 15px;
    }
    
  • @DownPW Thanks. Seems I forgot this

    [itemprop="author"] {
        float: left;
    }
    

    And this which will fix the overlap on the reply label

    .topic [component="post/parent"] {
        margin-left: 15px;
    }
    

    @phenomlab Ha yes very good thanks dude ๐Ÿ˜‰ Youโ€™re the best always ๐Ÿ˜‰

  • Screen Shot 2022-11-17 at 13.28.34.png

    actually, it looks very good (quite acceptable for our case ๐Ÿ™‚ ), thanks for the CSS codes; however CSS codes affect other group badges tooโ€ฆ

    group name: verified

    how can I restrict CSS codes to this group? I checked the inspector, I can only see group links, but not specific namesโ€ฆ

    @crazycells Letโ€™s try this

    In /forum/admin/manage/groups/verified, remove the highlighted section

    1c9e1406-d641-4e6c-8a03-e452c9462768-image.png

    We are then left with no text, but a clearer looking icon

    149c24c4-c95c-4a6e-8dc4-52340e4d0bed-image.png

    Now remove the previous CSS blocks I provided here

    Add replacement CSS

    .post-header a[href*="/forum/groups/verified"] {
        margin-right: 3px;
        margin-top: 1px;
        border-radius: 50%;
        line-height: 20px;
        display: inline-block;
        vertical-align: middle;
        text-align: center;
        overflow: hidden;
    }
    small.label.group-label.inline-block i {
        margin-top: 1px;
        margin-left: 0px;
        vertical-align: middle;
        justify-content: center;
        display: flex;
    }
    .post-header a[href*="/forum/groups/verified"] .group-label {
        min-width: 20px;
        display: flex;
        justify-content: center;
    }
    .group-label {
        vertical-align: -6px;
    }
    
    

    You should land up with something like this

    16a50d49-f765-46c9-a480-344a592baf13-image.png

    As you can see, this forces the stars out of alignment, but I donโ€™t think this is too much of a sacrifice, and could be remediated with additional targeted CSS if need be.

    Essentially, because NodeBB doesnโ€™t provide an id field (which would be a lot easier), we have to use wildcard CSS such as .post-header a[href*="/forum/groups/verified"] but make it targeted in the sense that it will only fire if it is part of the post stream, hence .post-header at the beginning.

    We then use .post-header a[href*="/forum/groups/verified"] .group-label to target the actual label (but only when we have a wildcard match in the CSS) meaning we can set a minimum width so that the circle doesnโ€™t look quashed (we need to validate this on Firefox though as additional CSS might be required due to how the webkit engine will render this in contrast to mozilla).

    Finally, we use .group-label to force alignment in terms of height to prevent it wandering out of the inline-block.

    This is already active on your forum, so nothing for you to do but (hopefully) admire ๐Ÿ™‚

    Let me know.

  • phenomlabundefined phenomlab referenced this topic on
  • @crazycells Letโ€™s try this

    In /forum/admin/manage/groups/verified, remove the highlighted section

    1c9e1406-d641-4e6c-8a03-e452c9462768-image.png

    We are then left with no text, but a clearer looking icon

    149c24c4-c95c-4a6e-8dc4-52340e4d0bed-image.png

    Now remove the previous CSS blocks I provided here

    Add replacement CSS

    .post-header a[href*="/forum/groups/verified"] {
        margin-right: 3px;
        margin-top: 1px;
        border-radius: 50%;
        line-height: 20px;
        display: inline-block;
        vertical-align: middle;
        text-align: center;
        overflow: hidden;
    }
    small.label.group-label.inline-block i {
        margin-top: 1px;
        margin-left: 0px;
        vertical-align: middle;
        justify-content: center;
        display: flex;
    }
    .post-header a[href*="/forum/groups/verified"] .group-label {
        min-width: 20px;
        display: flex;
        justify-content: center;
    }
    .group-label {
        vertical-align: -6px;
    }
    
    

    You should land up with something like this

    16a50d49-f765-46c9-a480-344a592baf13-image.png

    As you can see, this forces the stars out of alignment, but I donโ€™t think this is too much of a sacrifice, and could be remediated with additional targeted CSS if need be.

    Essentially, because NodeBB doesnโ€™t provide an id field (which would be a lot easier), we have to use wildcard CSS such as .post-header a[href*="/forum/groups/verified"] but make it targeted in the sense that it will only fire if it is part of the post stream, hence .post-header at the beginning.

    We then use .post-header a[href*="/forum/groups/verified"] .group-label to target the actual label (but only when we have a wildcard match in the CSS) meaning we can set a minimum width so that the circle doesnโ€™t look quashed (we need to validate this on Firefox though as additional CSS might be required due to how the webkit engine will render this in contrast to mozilla).

    Finally, we use .group-label to force alignment in terms of height to prevent it wandering out of the inline-block.

    This is already active on your forum, so nothing for you to do but (hopefully) admire ๐Ÿ™‚

    Let me know.

    @phenomlab

    Just one things my friend.

    I search a css class for display groupname on group icons mouse over but donโ€™t find it.
    if you have that in your hat Iโ€™m a taker ๐Ÿ˜‰

  • @phenomlab

    Just one things my friend.

    I search a css class for display groupname on group icons mouse over but donโ€™t find it.
    if you have that in your hat Iโ€™m a taker ๐Ÿ˜‰

    @DownPW Mmmmm, yes, the fastest way to do that would be to use the title attribute. Bootstrap has native support for that

    8e9af7a4-b69c-4573-93cb-72dce2d8bcf3-image.png

    If you added this attribute then hovered over the element, youโ€™d see this

    4cd5440b-649f-4817-be85-08ff54a8859b-image.png

    Itโ€™s possible to write jQuery to handle this - aside from that, youโ€™d need to hack into the post template which I wouldnโ€™t recommend. There isnโ€™t any native CSS that will do this for you sadly, so the title="" attribute is the best way forward but wonโ€™t do anything without custom JS.

    EDIT - I actually have a requirement for this myself, so will probably write some code to do it over the coming days/weeks (really depending on how much free time I have).


Did this solution help you?
Did you find the suggested solution useful? Support ๐Ÿ’— Sudonix with a coffee โ˜•
If your organisation needs deeper expertise around infrastructure, security, or technology leadership, learn more about Phenomlab Ltd. Many of the deeper technical guides behind Sudonix are published there.

Related Topics
  • www. Infront stops website access?

    Solved Configure nodebb
    10
    1 Votes
    10 Posts
    1k Views
    @Panda because there is no match for the DNS entry specified. The receiving web server parses the headers looking for a destination hostname to match, and anything the web server is unable to resolve will be sent back to the root.
  • nodebb loading emojis

    Solved Configure nodebb emojis
    16
    1
    1 Votes
    16 Posts
    3k Views
    @DownPW sure. Let me have a look at this in more detail. I know nginx plus has extensive support for this, but itโ€™s not impossible to get somewhere near acceptable with the standard version. You might be better off handling this at the Cloudflare level given that it sits in between the requesting client and your server.
  • NodeBB 3.0 alpha1 : Error on install

    Solved Configure nodebb version 3 install error
    19
    2 Votes
    19 Posts
    3k Views
    @phenomlab Work now
  • Recent Cards plugin customization

    Solved Customisation nodebb
    21
    1
    13 Votes
    21 Posts
    7k Views
    @pobojmoks thatโ€™s easily done by modifying the code provided here so that it targets background rather than border In essence, the below should work $(document).ready(function() { $(window).on('action:ajaxify.end', function(data) { $('.recent-card-container').each(function(i) { var dataId = $(this).attr("data-cid"); var color = $('[role="presentation"]', this).css("background-color"); console.log("data-cid " + dataId + " is " + color); $('[data-cid="' + dataId + '"] .recent-card').attr("style", "background-color: " + color); }); }); });
  • [NodeBB] Import custom Font

    Solved Customisation custom fonts nodebb css
    12
    3 Votes
    12 Posts
    3k Views
    @cagatay youโ€™ll need to define this in the body tag (or another element if you want greater or more granular targets) - for example body { font-family: "Poppins"; font-size: 16px; } Essentially, you use the font-size CSS directive.
  • [NodeBB] First post customization

    Solved Customisation nodebb
    5
    4 Votes
    5 Posts
    1k Views
    @phenomlab thanks
  • Social icon (Nodebb)

    Solved Customisation nodebb social
    7
    0 Votes
    7 Posts
    2k Views
    @phenomlab said in Social icon (Nodebb): @jac I just tested my theory around using the OG image, and according to the Twitter card validator, it works fine [image: 1638880098289-73e805e1-997b-41bf-9259-51c5052ca8fc-image.png] fixed
  • RSS parser script [NodeBB]

    Customisation nodebb rss script
    47
    9 Votes
    47 Posts
    12k Views
    @phenomlab said in RSS parser script [NodeBB]: @jac Not yet. Sorry. Have some other work commitments I need to prioritise. Hoping to get to this over the weekend. No worries at all mate, thanks