Skip to content

Custom badges

Solved Customisation
103 4 25.6k 2
  • @phenomlab sure, here is how I see it:

    Screen Shot 2022-11-21 at 15.49.47.png

    @crazycells ah, yes, I know why. There’s a class I haven’t committed.

    Thanks. I’ll sort that out tomorrow.

  • @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 said in Custom badges:

    @crazycells @DownPW something of a “fresher” approach. Have a look at the below

    5602e864-6de6-4a09-9dd1-eb33b2807774-image.png

    Using the messenger type view I created, it then becomes possible to place the “verified” group according to the style from the same view.

    This does mean some new CSS

    .self-post a[href*="/groups/verified"] .group-label {
        position: absolute !important;
        right: 51px;
        top: 44px;
    }
    .topic-response-post a[href*="/groups/verified"] .group-label {
        position: absolute !important;
        left: 20px;
        top: 44px;
    }
    .topic-response-post i[component="user/status"] {
        position: absolute;
        left: -1px;
    }
    

    And, more importantly, I found a more efficient way of adding classes in the messenger view js. The revised code is below

    // Target those elements already loaded in the DOM
    $(document).ready(function() {
        $(window).on('action:ajaxify.end', function(data) {
            $('li[component="post"]').each(function(i, obj) {
                if (!$(this).hasClass('self-post') || (!$(this).hasClass('self-post'))) {
                    console.log("Adding required classes for messenger type view");
                    $(this).addClass('topic-response-post');
                }
    
            });
        });
    });
    // Target elements dynamically added to the DOM on post load
    $(document).ready(function() {
        $(window).on('action:ajaxify.loaded', function(data) {
            $('li[component="post"]').each(function(i, obj) {
                if (!$(this).hasClass('self-post') || (!$(this).hasClass('self-post'))) {
                    console.log("Adding required classes for messenger type view");
                    $(this).addClass('topic-response-post');
                }
    
            });
        });
    });
    

    My style looks like it with those codes. There isjust seems some blue color of my checked icon 🙂

    ab44fb86-a985-4bbb-b6ab-284c80831859-image.png

  • cagatayundefined cagatay referenced this topic on
  • @phenomlab said in Custom badges:

    @crazycells @DownPW something of a “fresher” approach. Have a look at the below

    5602e864-6de6-4a09-9dd1-eb33b2807774-image.png

    Using the messenger type view I created, it then becomes possible to place the “verified” group according to the style from the same view.

    This does mean some new CSS

    .self-post a[href*="/groups/verified"] .group-label {
        position: absolute !important;
        right: 51px;
        top: 44px;
    }
    .topic-response-post a[href*="/groups/verified"] .group-label {
        position: absolute !important;
        left: 20px;
        top: 44px;
    }
    .topic-response-post i[component="user/status"] {
        position: absolute;
        left: -1px;
    }
    

    And, more importantly, I found a more efficient way of adding classes in the messenger view js. The revised code is below

    // Target those elements already loaded in the DOM
    $(document).ready(function() {
        $(window).on('action:ajaxify.end', function(data) {
            $('li[component="post"]').each(function(i, obj) {
                if (!$(this).hasClass('self-post') || (!$(this).hasClass('self-post'))) {
                    console.log("Adding required classes for messenger type view");
                    $(this).addClass('topic-response-post');
                }
    
            });
        });
    });
    // Target elements dynamically added to the DOM on post load
    $(document).ready(function() {
        $(window).on('action:ajaxify.loaded', function(data) {
            $('li[component="post"]').each(function(i, obj) {
                if (!$(this).hasClass('self-post') || (!$(this).hasClass('self-post'))) {
                    console.log("Adding required classes for messenger type view");
                    $(this).addClass('topic-response-post');
                }
    
            });
        });
    });
    

    My style looks like it with those codes. There isjust seems some blue color of my checked icon 🙂

    ab44fb86-a985-4bbb-b6ab-284c80831859-image.png

    @cagatay you should remove those two CSS blocks your referenced as that’s what’s causing the odd looking blue circles over the avatar.

  • @cagatay you should remove those two CSS blocks your referenced as that’s what’s causing the odd looking blue circles over the avatar.

    @phenomlab which one i should remove?

  • @phenomlab which one i should remove?

    @cagatay These

    .self-post a[href*="/groups/verified"] .group-label {
        position: absolute !important;
        right: 51px;
        top: 44px;
    }
    .topic-response-post a[href*="/groups/verified"] .group-label {
        position: absolute !important;
        left: 20px;
        top: 44px;
    }
    .topic-response-post i[component="user/status"] {
        position: absolute;
        left: -1px;
    }
    
  • @cagatay These

    .self-post a[href*="/groups/verified"] .group-label {
        position: absolute !important;
        right: 51px;
        top: 44px;
    }
    .topic-response-post a[href*="/groups/verified"] .group-label {
        position: absolute !important;
        left: 20px;
        top: 44px;
    }
    .topic-response-post i[component="user/status"] {
        position: absolute;
        left: -1px;
    }
    

    @phenomlab its not work, nothing changed when i deleted those css.

  • @phenomlab its not work, nothing changed when i deleted those css.

    @cagatay what isn’t working?

  • @cagatay what isn’t working?

    @phenomlab there is no changes after deleted css code;

    60f4bfa0-cc9e-4815-8044-9c38fb58769b-image.png

  • @cagatay what isn’t working?

    @phenomlab how can i set blue tick like sudonix to my own? coz codes which you are shared, it not look like yours;

    06a99cc4-2894-4284-84c5-cca50d0119cc-image.png

  • @phenomlab how can i set blue tick like sudonix to my own? coz codes which you are shared, it not look like yours;

    06a99cc4-2894-4284-84c5-cca50d0119cc-image.png

  • phenomlabundefined phenomlab referenced this topic on
  • @phenomlab i read it and did it what you wrote. but result as below;

    42761f89-4153-4945-967a-10afddf478fc-image.png

    blue icon not seen, it hide by avatar 🙂

  • @phenomlab i read it and did it what you wrote. but result as below;

    42761f89-4153-4945-967a-10afddf478fc-image.png

    blue icon not seen, it hide by avatar 🙂

    @cagatay Yes, having checked, I see what you mean. I’ve fixed this on your site.

    This is the new applied code

    .post-header a[href*="/groups/onaylı-üyeler"] {
        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*="/groups/onaylı-üyeler"] .group-label {
        min-width: 20px;
        display: flex;
        justify-content: center;
    }
    .self-post a[href*="/groups/onaylı-üyeler"] .group-label {
        position: absolute !important;
        right: 51px;
        top: 44px;
        z-index: 2;
    }
    .topic-response-post a[href*="/groups/onaylı-üyeler"] .group-label {
        position: absolute !important;
        left: 20px;
        top: 44px;
        z-index: 2;
    }
    .topic-response-post i[component="user/status"] {
        position: absolute;
        left: -1px;
    }
    .group-label {
        vertical-align: -6px;
    }
    

    However, there were some errors on your part. You were correct in renaming the actual group in CSS (good call) because of the language not being English, but the path was incorrect. You used the below, which was customized for @crazycells install 🙂

    /forum/groups/onaylı-üyeler
    

    It should be

    /groups/onaylı-üyeler
    

    You also have some overriding CSS somewhere that defines a lower z-index value which forces the “verified” icon behind the avatar, so I’ve added an adjustment for that

    z-index: 2;
    
  • @cagatay Yes, having checked, I see what you mean. I’ve fixed this on your site.

    This is the new applied code

    .post-header a[href*="/groups/onaylı-üyeler"] {
        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*="/groups/onaylı-üyeler"] .group-label {
        min-width: 20px;
        display: flex;
        justify-content: center;
    }
    .self-post a[href*="/groups/onaylı-üyeler"] .group-label {
        position: absolute !important;
        right: 51px;
        top: 44px;
        z-index: 2;
    }
    .topic-response-post a[href*="/groups/onaylı-üyeler"] .group-label {
        position: absolute !important;
        left: 20px;
        top: 44px;
        z-index: 2;
    }
    .topic-response-post i[component="user/status"] {
        position: absolute;
        left: -1px;
    }
    .group-label {
        vertical-align: -6px;
    }
    

    However, there were some errors on your part. You were correct in renaming the actual group in CSS (good call) because of the language not being English, but the path was incorrect. You used the below, which was customized for @crazycells install 🙂

    /forum/groups/onaylı-üyeler
    

    It should be

    /groups/onaylı-üyeler
    

    You also have some overriding CSS somewhere that defines a lower z-index value which forces the “verified” icon behind the avatar, so I’ve added an adjustment for that

    z-index: 2;
    

    @phenomlab ah okey Mark 🙂 you as always better then me so there is no word in my side for the explaniton 🙂

    thank you again.

  • @phenomlab ah okey Mark 🙂 you as always better then me so there is no word in my side for the explaniton 🙂

    thank you again.

    @cagatay said in Custom badges:

    @phenomlab ah okey Mark 🙂 you as always better then me so there is no word in my side for the explaniton 🙂

    thank you again.

    hi @cagatay , as a first step you have to create a group called “verified” , then everything is as it is written on this thread… but since your group name was different, it gave an error…

    I am writing this explicitly so that others can be aware.

  • @cagatay said in Custom badges:

    @phenomlab ah okey Mark 🙂 you as always better then me so there is no word in my side for the explaniton 🙂

    thank you again.

    hi @cagatay , as a first step you have to create a group called “verified” , then everything is as it is written on this thread… but since your group name was different, it gave an error…

    I am writing this explicitly so that others can be aware.

    @crazycells said in Custom badges:

    I am writing this explicitly so that others can be aware.

    Good point. Thanks

  • @crazycells said in Custom badges:

    I am writing this explicitly so that others can be aware.

    Good point. Thanks

    @phenomlab i have problem with my badges for ios and android users.

    i can secret all of from mobile users?

  • @phenomlab i have problem with my badges for ios and android users.

    i can secret all of from mobile users?

    @cagatay Are they showing on mobile ? Can you send a screenshot ?

  • @cagatay Are they showing on mobile ? Can you send a screenshot ?

    @phenomlab sure,

    58aec53e-de00-4dee-a113-37f74ccbf338-image.png

  • @cagatay Do you want the icon to show? Because of the size of the screen estate, I think it makes more sense to hide it?

  • @cagatay Do you want the icon to show? Because of the size of the screen estate, I think it makes more sense to hide it?

    @phenomlab i want to hide them.


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
  • What plugins are being used here on Sudonix?

    Solved General nodebb plugins development
    6
    5 Votes
    6 Posts
    1k Views
    @Roki-Antic Welcome! This site isn’t running Persona, but Harmony - a very heavily customised version at that. Do you have a URL where your site is currently located that is publicly accessible? Feel free to PM this info if you do not want to disclose here. Happy to help with any customisation needs.
  • Custom html in nodebb to prevent cache

    Unsolved Configure nodebb
    18
    2 Votes
    18 Posts
    3k Views
    @Panda You’ll need to do that with js. With some quick CSS changes, it looks like this [image: 1690796279348-d619844f-fbfe-4cf1-a283-6b7364f6bf18-image.png] The colour choice is still really hard on the eye, but at least you can now read the text
  • Nodebb design

    Solved General nodebb
    2
    1 Votes
    2 Posts
    844 Views
    @Panda said in Nodebb design: One negative is not being so good for SEO as more Server side rendered forums, if web crawlers dont run the JS to read the forum. From recollection, Google and Bing have the capability to read and process JS, although it’s not in the same manner as a physical person will consume content on a page. It will be seen as plain text, but will be indexed. However, it’s important to note that Yandex and Baidu will not render JS, although seeing as Google has a 90% share of the content available on the web in terms of indexing, this isn’t something you’ll likely lose sleep over. @Panda said in Nodebb design: The “write api” is preferred for server-to-server interactions. This is mostly based around overall security - you won’t typically want a client machine changing database elements or altering data. This is why you have “client-side” which could be DOM manipulation etc, and “server-side” which performs more complex operations as it can communicate directly with the database whereas the client cannot (and if it can, then you have a serious security flaw). Reading from the API is perfectly acceptable on the client-side, but not being able to write. A paradigm here would be something like SNMP. This protocol exists as a UDP (UDP is very efficient, as it is “fire and forget” and does not wait for a response like TCP does) based service which reads performance data from a remote source, thus enabling an application to parse that data for use in a monitoring application. In all cases, SNMP access should be “RO” (Read Only) and not RW (Read Write). It is completely feasible to assume complete control over a firewall for example by having RW access to SNMP and then exposing it to the entire internet with a weak passphrase. You wouldn’t do it (at least, I hope you wouldn’t) and the same ethic applies to server-side rendering and the execution of commands.
  • NodeBB: Consent page

    Solved Configure nodebb consent
    16
    4 Votes
    16 Posts
    4k Views
    @DownPW I still do not see any issues.
  • NodeBB Theme/Skin Switcher

    Solved Customisation nodebb
    38
    7 Votes
    38 Posts
    8k Views
    @Teemberland great spot ! You should create a PR for that so they can include it in the official repository. Just be aware that any subsequent releases will overwrite your fix without the PR.
  • 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] greeting message

    Solved Customisation css nodebb javascript
    2
    1
    3 Votes
    2 Posts
    1k Views
    @pwsincd welcome to sudonix, and thanks for the comments. What your looking for is here https://sudonix.com/topic/195/nodebb-welcome-message/3?_=1648295651358
  • [NodeBB] First post customization

    Solved Customisation nodebb
    5
    4 Votes
    5 Posts
    1k Views
    @phenomlab thanks