Support Forum

Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
plugins-topic
Forum and member stats
Avatar
Meztli
Sweden
Member
sp_UserOfflineSmall Offline
Feb 2, 2015 - 12:05 pm

Hi guys,

Is there any way to pull the forum and member stats into a widget on my website frontpage?

Cheers

Avatar
Ike
Sawtry, UK
Member
Free Members
sp_UserOfflineSmall Offline
Feb 2, 2015 - 2:40 pm

hey Meztli,

I've not played around with widgets too much so this seemed like a good opportunity to me!

It was actually pretty straight forward to display these two stats items in a widget. Firstly you will want to use the 'Text' widget, put it where you want it to display and open it to edit.

Then open your themes spFoot.php and find the two functions you want to display - In this case 'sp_ForumStats' and 'sp_MembershipStats'. Select each function in their entirety and copy them into the text widget, wrapping them in PHP tags:

<?php

sp_ForumStats('tagClass=spRight', __sp('Forum Stats: '), __sp('Groups: '), __sp('Forums: '), __sp('Topics: '), __sp('Posts: '));

sp_MembershipStats('tagClass=spRight', __sp('Member Stats: '), __sp('Members: %COUNT%'), __sp('Guest Posters: %COUNT%'), __sp('Moderators: %COUNT%'), __sp('Admins: %COUNT%'));

?>

That's pretty much it to get the stats to display - you have the option then of styling. All the elements of the widget are made up of the same classes as are used on the forum, but because they are outside of the forum they get their style from the WP theme so you will want to make any style changes there. You can target them using the .textwidget class, so for example:

.textwidget    .spForumStatsTitle {
        font-weight: bold;
    }

- Should work. You might need to have a play around with that part!

Hope that helps!

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Feb 2, 2015 - 2:56 pm

Just need to add what Ike left out, You will need a plugin that deals with using php in a widget.  There are several out there. We use one called php-exec. Invaluable.

andy-signature.png
YELLOW
SWORDFISH
Avatar
Ike
Sawtry, UK
Member
Free Members
sp_UserOfflineSmall Offline
Feb 2, 2015 - 6:51 pm

That's two things I've learnt today :)

Avatar
Meztli
Sweden
Member
sp_UserOfflineSmall Offline
Feb 3, 2015 - 5:14 am

Thank you guys, terrific! smile

I used the php-exec plugin on my old website and we had some issues with it.

However since we are now using the Genesis framework (new website since january), it migth work better, but i have to try it out on our test site before going live with it at http://friskyttarna.eu

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Feb 3, 2015 - 6:08 am

We use it here but am not convinced t is the best one. There is one called, I believe, wp-exec (I think) which I have had no issues with.

andy-signature.png
YELLOW
SWORDFISH
Forum Timezone: Europe/Stockholm
Most Users Ever Online: 1170
Currently Online:
Guest(s) 1
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Mr Papa: 19448
Ike: 2086
Brandon: 864
kvr28: 804
jim: 650
FidoSysop: 577
Conrad_Farlow: 531
fiddlerman: 358
Stefano Prete: 325
Member Stats:
Guest Posters: 619
Members: 17363
Moderators: 0
Admins: 4
Forum Stats:
Groups: 7
Forums: 17
Topics: 10127
Posts: 79625