The forum of the forums

Would you like to react to this message? Create an account in a few clicks or log in to continue.
The forum of the forums
2 posters

    Number of group members in legend

    Zwiebel
    Zwiebel
    New Member


    Posts : 7
    Reputation : 1
    Language : English

    Solved Number of group members in legend

    Post by Zwiebel January 11th 2023, 11:43 am

    Hello,

    I was wondering if somebody already posted a way to automatically display the number of people in a group e.g. next to the groupname in the legend. I'm aware it's not a function of forumotion itself and I would have to do it manually currently.


    Example would be:

    [Adminstrators: 3] [Newbies: 5] [Warriors: 21] [Archers: 12], etc

    or something along those lines?


    Best,
    Zwiebel


    Last edited by Zwiebel on January 11th 2023, 1:40 pm; edited 2 times in total
    avatar
    Guest
    Guest


    Solved Re: Number of group members in legend

    Post by Guest January 11th 2023, 11:56 am

    What is your forum version?
    Zwiebel
    Zwiebel
    New Member


    Posts : 7
    Reputation : 1
    Language : English

    Solved Re: Number of group members in legend

    Post by Zwiebel January 11th 2023, 11:59 am

    modernBB
    avatar
    Guest
    Guest


    Solved Re: Number of group members in legend

    Post by Guest January 11th 2023, 12:08 pm

    Will write later script.
    avatar
    Guest
    Guest


    Solved Re: Number of group members in legend

    Post by Guest January 11th 2023, 1:16 pm

    Here you go. Go to CP - Modules - Javascript, make a new script and apply only for homepage. Add this code:

    Code:
    $(document).ready(function() {

        var numberOfGroups = $(".block-footer b a").length;

        for (i = 0; i < numberOfGroups; i++) {
            var titleValue = $(".block-footer b a")[i].getAttribute("title");
            var numberOfUsers = titleValue.slice(titleValue.indexOf(":"));
            var originalText = $(".block-footer b a")[i].innerHTML;
            $(".block-footer b a")[i].innerHTML = originalText + numberOfUsers;
        }

    });

    Save. Let me know the results. For me it works like this:
    Number of group members in legend Scree152
    Zwiebel
    Zwiebel
    New Member


    Posts : 7
    Reputation : 1
    Language : English

    Solved Re: Number of group members in legend

    Post by Zwiebel January 11th 2023, 1:26 pm

    aaaaww men, this is so smart and simple! thank you. I saw that they basically give you the number in the title of the link but I wouldn't have known how to extract it.

    works just fine <3
    avatar
    Guest
    Guest


    Solved Re: Number of group members in legend

    Post by Guest January 11th 2023, 1:35 pm

    Zwiebel wrote:aaaaww men, this is so smart and simple! thank you. I saw that they basically give you the number in the title of the link but I wouldn't have known how to extract it.

    works just fine <3
    Yeah, simple slice method does the trick.
    skouliki
    skouliki
    Manager
    Manager


    Female Posts : 15311
    Reputation : 1705
    Language : English,Greek
    Location : Greece

    Solved Re: Number of group members in legend

    Post by skouliki January 11th 2023, 3:20 pm

    Problem solved & topic archived.
    Please read our forum rules: ESF General Rules


      Current date/time is September 22nd 2024, 3:17 pm