Welcome to Geeklog Sunday, September 15 2019 @ 06:15 pm EDT

Geeklog Forums

Is there a way to display how many users my site has?


Status: offline

kilerb

Forum User
Regular Poster
Registered: 19/03/08
Posts: 119
But without a link to the list?

Basically a non-clickable number in a sentence that says "This site is up to XXX members and counting!" or something like that. I'd rather them not be able to see the list though.

Thanks!

Status: offline

ofey

Forum User
Full Member
Registered: 18/03/05
Posts: 213
Location:Dublin, Ireland
The following php will give you the number of registered users to your site. Create a staticpage with php enabled with:

PHP Formatted Code
global $_TABLES;

$count = DB_Count($_TABLES['users']) - 1;
echo " $count ";

This will count the number of rows in the table with all the users. The -1 is to take out the anonymous user.

Then use an autotag if geeklog supports them
[code] [ staticpage_content:pageID ] [\code]

This autotag just goes into the article or where ever you want the variable which is the number of registered users. The page ID is the ID for the staticpage you created.

Geeklog autotag documentation http://www.geeklog.net/docs/english/staticpages.html#autotags.

Shane
Those who say it can't be done, are usually interrupted by others doing it.

Status: offline

Dirk

Site Admin
Admin
Registered: 12/01/02
Posts: 13073
Location:Stuttgart, Germany
Where do you want to display that? For a side block, you could create a simple PHP function and display it in a PHP block. Otherwise, use CUSTOM_templateSetVars to define a new template variable (see sample code in lib-custom.php).

For a simple count, use something like
PHP Formatted Code
$num_users = DB_count($_TABLES['users']) - 1;

(the -1 is to not count the Anonymous user account). That would also include all users who were banned or created an account but never logged in. Too lazy now to look up how to exclude those, sorry :wink:

bye, Dirk

Status: offline

kilerb

Forum User
Regular Poster
Registered: 19/03/08
Posts: 119
Thanks Ofey and Dirk... What's the echo line for in yours Ofey?

I'd almost like it to be in the header or a sideblock would be cool if it didn't take too much room. I'd like it to be sort of big... (The number, not necessarily the text before it...)

Like this...

<small font>This site now has
<big font>XXX
<small font>members, and counting!

All centered..

Status: offline

ofey

Forum User
Full Member
Registered: 18/03/05
Posts: 213
Location:Dublin, Ireland
Hi kilerb,

The echo prints the number of registered users to a staticpage. Without it your staticpage would have no content. Then the autotag takes the content of that staticpage which in this case is the number of registered users and puts it where you want it or wherever you put the staticpage_content autotag. You will end up using:

<small font>This site now has
<big font>[ staticpage_content:pageID]
<small font>members, and counting!

I would advise you first to create the staticpage and make sure it is working correctly first, then add the autotag to you block.

Let us know how you get on.

Thanks,

Shane
Those who say it can't be done, are usually interrupted by others doing it.

Status: offline

kilerb

Forum User
Regular Poster
Registered: 19/03/08
Posts: 119
Thanks! Worked great... How can I make the number bigger or bold?

Thanks again...


Status: offline

ofey

Forum User
Full Member
Registered: 18/03/05
Posts: 213
Location:Dublin, Ireland
Hi,

I imagine basic HTML tags will do it. Something like,

<b>[staticpage....]</b> and so on.

But you should be able to use the advanced editor when writing blocks.

Shane


Those who say it can't be done, are usually interrupted by others doing it.

Status: offline

kilerb

Forum User
Regular Poster
Registered: 19/03/08
Posts: 119
Thanks a lot, looks great...

All times are EDT. The time is now 06:15 pm.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content