Announcement

Collapse
No announcement yet.

Remove Active Members Statistic

Collapse
X
Collapse
First Prev Next Last
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Free Mod Remove Active Members Statistic

    For forum sites that are not that active or are just starting, showing the Active Members statistic is not good for members to see.

    It would have been easy to hide it via CSS as you normally would but the way the statistics are displayed, it's not possible as they are all inside a <div> tag and doesn't have its own tag. See sample below: I found a way to hide a statistic without editing widget_statistics template or adding some crazy Javascript. So ignore all the code below and head over to this thread.


    HTML Code:
    <div class="h-margin-bottom-s">
        Topics: 123 &nbsp;
        Posts: 456 &nbsp;
        Members: 789 &nbsp;
        Active Members: 10
    </div>
    This prevents you to hide some parts of the div content as that is not possible in CSS. It would have been possible if each statistic is in its own tag like below:

    HTML Code:
    <div class="h-margin-bottom-s">
        <span>Topics: 123 &nbsp;</span>
        <span>Posts: 456 &nbsp;</span>
        <span>Members: 789 &nbsp;</span>
        <span>Active Members: 10</span>
    </div>
    In the code above, you could have targeted the 4th span in CSS and hide it.

    Now that you've seen what the problem is, here are possible solutions:

    For self-hosted version:

    1. Edit widget_statistics template in Style Manager in AdminCP.
    2. Find this line:
    Code:
    {vb:rawphrase active_members_x, {vb:number {vb:var statistics.activeMembers}}}
    3. Remove it by commenting it out. You do it by enclosing the code in <vb:comment> </vb:comment> tags:
    Code:
    <vb:comment>{vb:rawphrase active_members_x, {vb:number {vb:var statistics.activeMembers}}}</vb:comment>
    4. Save.
    5. Repeat for every active theme/style you are using.


    For vBCloud:

    1. Go to homepage or where the Forum Statistics module is.
    2. Find out the widget id of the Forum Statistics module by right clicking on it and inspecting the element.
    3. Look for id="widget_XXXX" where XXXX is a number. Take note of this widget id.
    4. Enable Sitebuilder (Edit Site ON)
    5. Click Edit Page.
    6. Drag and drop Static HTML module onto the page right BELOW the Forum Statistics module.
    7. Edit the Static HTML module configuration.
    8. Uncheck all the 3 checkboxes for the "Show module at these screen sizes" option.
    9. Copy and paste the code below to the "Module HTML" option.
    Code:
    <script>
    (function() {
        var statsWidgetId = '#widget_5',                // change to the id of your Forum Statistics module
            activeMembersLabel = ['Active Members:'],    // change to the appropriate label(s) if translated to something else
    
            // DO NOT CHANGE ANYTHING BELOW!!!
            el = document.querySelector(statsWidgetId + ' .widget-content'),
            el2 = el && el.firstElementChild,
            regex;
    
        if (el2) {
            for (var i = 0; i < activeMembersLabel.length; i++) {
                regex = new RegExp(activeMembersLabel[i] + ' \\d{1,3}(,\\d{3})*(\\.\\d+)?');
                if (el2.textContent.match(regex)) {
                    el2.textContent = el2.textContent.replace(regex, '');
                    break;
                }
            }
        }
    })();
    </script>
    10. Change the value of the statsWidgetId variable with the value you got from Step 3. Do not remove the quotes around it.
    11. Change the value of the activeMembersLabel variable as needed. If you are using non-English language, you need to change this accordingly. If you are using multiple languages, you need to add them like this:
    Code:
    activeMembersLabel = ['Active Members:', 'Membres Actifs:', 'Miembros Activos:'],
    12. Save the module and page as you normally would.


    That's it! Enjoy!
    Last edited by glennrocksvb; 06-13-2018, 01:05 AM. Reason: Linked to a new and better solution. Original code not recommended anymore.
    Helpful? Donate. Thanks!
    Buy me a coffeePayPal QR Code
    Fast VPS Host for vBulletin:
    A2 Hosting & IONOS

    #2
    Glenn that worked beautifully
    Happy New Year and BAG the coffee.. Dinner is on it's way
    Thanks for all your free help throughout the year

    Comment


    • glennrocksvb
      glennrocksvb commented
      Editing a comment
      Glad to help!

    • glennrocksvb
      glennrocksvb commented
      Editing a comment
      Thanks for the treat as always!

    #3
    I think I will give this a try. I did not like that was placed there to begin with.

    Update: Nice

    Comment


      #4
      I'm still thankful that Glenn was able to come up with this fix

      Comment


        #5
        The original code is not recommended anymore as I found a better solution. First post updated with link to a new solution.
        Helpful? Donate. Thanks!
        Buy me a coffeePayPal QR Code
        Fast VPS Host for vBulletin:
        A2 Hosting & IONOS

        Comment


          #6
          thanks

          Comment

          Users Viewing This Page

          Collapse

          There is 1 user viewing this forum topic.

          • Guest Guest

          Latest Posts

          Collapse

          Working...
          X
          Searching...Please wait.
          An unexpected error was returned: 'Your submission could not be processed because you have logged in since the previous page was loaded.

          Please push the back button and reload the previous window.'
          An unexpected error was returned: 'Your submission could not be processed because the token has expired.

          Please push the back button and reload the previous window.'
          An internal error has occurred and the module cannot be displayed.
          There are no results that meet this criteria.
          Search Result for "|||"