Форумы

The great place to discuss topics with other users

To display amount of users already joined your network

'
Join the Conversation Ответить
Edy Lee
Admin
Joined: 2024-11-24 00:57:42
2025-09-29 01:42:24

Add in your index.php:

// count all users
$get_total_users = $db->query("SELECT COUNT(*) as count FROM users") or _error("SQL_ERROR");
$total_users = (int) $get_total_users->fetch_assoc()['count'];

// assign to smarty
$smarty->assign('total_users', $total_users);

 
 

Step 2 – Display in index.landing.tpl

 
<div class="landing-users-count text-center mt-4"> <h3>{$total_users|number_format}</h3> <p>Members have already joined</p> </div>
Edy Lee
Admin
Joined: 2024-11-24 00:57:42
2025-09-29 02:21:40

fun  little trick 

{* Users joined counter with smooth viral effect *}
        <div class="mt-4 text-white hero-fade-slide delay-4 position-relative">
          <h3 class="fw-bold mb-1" id="user-counter">{$total_users|number_format}</h3>
          <p class="mb-0">Users already joined</p>
        </div>

 

{* Smooth viral counter script compatible with Smarty *}
<script>
document.addEventListener("DOMContentLoaded", function() {
  var el = document.getElementById("user-counter");
  var currentUsers = {$total_users};  // actual total users from DB

  // Function to increment counter smoothly
  function incrementCounter(amount) {
    var start = currentUsers;
    var end = currentUsers + amount;
    var duration = 800; // animation duration
    var startTime = null;

    function step(timestamp) {
      if (!startTime) startTime = timestamp;
      var progress = Math.min((timestamp - startTime) / duration, 1);
      var value = Math.floor(start + (end - start) * progress);
      el.textContent = value.toLocaleString();
      if (progress < 1) requestAnimationFrame(step);
    }
    requestAnimationFrame(step);
    currentUsers = end;
  }

  // Show small viral +1 effect visually
  function showPopup(amount) {
    var popup = document.createElement('div');
    popup.textContent = '+' + amount; // plain concatenation works with Smarty
    popup.style.position = 'absolute';
    popup.style.color = '#00ffcc';
    popup.style.fontWeight = 'bold';
    popup.style.top = (Math.random() * 40 + 0) + '%';
    popup.style.left = (Math.random() * 60 + 20) + '%';
    popup.style.opacity = '1';
    popup.style.transition = 'all 1s ease-out';
    el.parentElement.appendChild(popup);

    setTimeout(function() {
      popup.style.top = (parseFloat(popup.style.top) - 20) + '%';
      popup.style.opacity = '0';
    }, 50);

    setTimeout(function() {
      popup.remove();
    }, 1000);
  }

  // Increment counter periodically based on real users
  setInterval(function() {
    var newUsers = Math.floor(Math.random() * 3 + 1); // 1-3 new users
    incrementCounter(newUsers);
    showPopup(newUsers);
  }, 4000); // every 4 seconds
});
</script>

Richard  Wing
Member
Joined: 2025-01-18 19:22:40
2025-10-03 07:29:22

Could this be created as a plugin/addon with Jane's plugin system?

Mike Sieck
Member
Joined: 2025-12-28 00:13:09
2025-12-28 02:29:43

Is it also possible to display the number of users who are currently online?

Edy Lee
Admin
Joined: 2024-11-24 00:57:42
2025-12-29 13:21:38

Yes  anyone can develop it futher