Exclude a certain username from the Top Poster code using SSL?

Started by swiftmed, March 30, 2010, 05:05:14 PM

Previous topic - Next topic

swiftmed

Hey Guys,

Quick question. As the administrator of my Forum, I am the person with the most amount of posts to my name. But i like to display the top poster on my main websites home page using the SSL.php feature. Is there any way i can show the 2nd highest top poster, and exclude my username from the list???

As much as I am the top poster, Im not fussed about being named as top poster, so would rather the 2nd highest poster gets the recognition from it?
With Regards,
Andrew MacDonald

http://cherylanncole.co.uk/forums
SMF 2.0 RC2

Arantor

Easy one to change but it has to be done in SSI.php itself.

There's actually two ways to do it.

1. If you can guarantee you will always be the #1 poster. This method is faster and therefore recommended.
function ssi_topPoster($topNumber = 1, $output_method = 'echo')
{
global $db_prefix, $scripturl, $smcFunc;

// Find the latest poster.
$request = $smcFunc['db_query']('', '
SELECT id_member, real_name, posts
FROM {db_prefix}members
ORDER BY posts DESC
LIMIT ' . $topNumber,
array(
)
);


The key line is the one with the limit in. You would change it to:
LIMIT 1, ' . $topNumber,

This will make it always consider the 2nd actual highest as 'highest'. Note that the main forum stats page isn't affected by this.

2. Excluding yourself from it. Slight performance hit by comparison but guaranteed to exclude only you.
function ssi_topPoster($topNumber = 1, $output_method = 'echo')
{
global $db_prefix, $scripturl, $smcFunc;

// Find the latest poster.
$request = $smcFunc['db_query']('', '
SELECT id_member, real_name, posts
FROM {db_prefix}members
WHERE id_member != {int:id}
ORDER BY posts DESC
LIMIT ' . $topNumber,
array(
'id' => 1,
)
);


The 1 is your user id, as it's your site I figure you're the first user account. Change that if not. Again this also won't touch the main stats page.

swiftmed

With Regards,
Andrew MacDonald

http://cherylanncole.co.uk/forums
SMF 2.0 RC2

Advertisement: