Topic: Styling the onlinenames...
It would be nice if the names in the onlinelist was styled on a way or another depending on the user status (Administrator, Moderator, User). Something to add to the 1.2?
You are not logged in. Please login or register.
PunBB Forums → Feature requests → Styling the onlinenames...
It would be nice if the names in the onlinelist was styled on a way or another depending on the user status (Administrator, Moderator, User). Something to add to the 1.2?
have you noticed the setting where you can choose "Show users of status" and be able to select Admins, Moderators, Members or all?
or do you mean they should have different colors and stuff?
yeah i think thats his point
would like it too
have you noticed the setting where you can choose "Show users of status" and be able to select Admins, Moderators, Members or all?
or do you mean they should have different colors and stuff?
Yeah, bold and italic would work fine for me.
OK, one sec and I'll see what you would have to modify.
Edit:
index.php
FIND:
$result = $db->query('SELECT id, username FROM '.$db->prefix.'users ORDER BY registered DESC LIMIT 1') or error('Unable to fetch newest registered user', __FILE__, __LINE__, $db->error());
$stats['last_user'] = $db->fetch_assoc($result);
REPLACE WITH:
$result = $db->query('SELECT id, username,status FROM '.$db->prefix.'users ORDER BY registered DESC LIMIT 1') or error('Unable to fetch newest registered user', __FILE__, __LINE__, $db->error());
$stats['last_user'] = $db->fetch_assoc($result);
FIND:
while ($cur_user_online = $db->fetch_assoc($result))
{
if ($cur_user_online['user_id'] > 0)
$users[] = '<a href="profile.php?id='.$cur_user_online['user_id'].'">'.pun_htmlspecialchars($cur_user_online['ident']).'</a>';
else
++$num_guests;
}
REPLACE WITH
while ($cur_user_online = $db->fetch_assoc($result))
{
if ($cur_user_online['user_id'] > 0)
{
if ($stats['last_user'] > PUN_USER)
$users[] = '<i><a href="profile.php?id='.$cur_user_online['user_id'].'">'.pun_htmlspecialchars($cur_user_online['ident']).'</a></i>';
else
$users[] = '<a href="profile.php?id='.$cur_user_online['user_id'].'">'.pun_htmlspecialchars($cur_user_online['ident']).'</a>';
}
else
++$num_guests;
}
That will make any mods/admins who are online show up in italics (substitute other HTML for the <i> and </i>s if you wish)
Edit: Fixed, ty Rickard, and silly me
If you are going to do that why not put a class on the <a> instead then you can style them how you wish via the stylesheet.
<a class="vipuser" href etc
Smartys: That won't work. $cur_user is you, not the user on the list :) You have to join in the users table.
Am I safe in assuming this is not going to be a standard feature
LMAO, silly me
/me makes the change
Am I safe in assuming this is not going to be a standard feature :)
Yes :)
Smartys: thanks! The code worked fine
No problem.
But thank Rickard, without him you would have had a non working chunk of code
This does not work on punBB 1.2.7, I get an error saying 'Registered user cannot be fetched.'
I'm going to write this up for 1.2.7
I'm not even sure how this code would have worked in 1.1.5, it fetched from the wrong query (I think) :-/
index.php
FIND:
$result = $db->query('SELECT user_id, ident FROM '.$db->prefix.'online WHERE idle=0 ORDER BY ident', true) or error('Unable to fetch online list', __FILE__, __LINE__, $db->error());
REPLACE WITH:
$result = $db->query('SELECT o.user_id, o.ident, u.group_id AS status FROM '.$db->prefix.'online AS o INNER JOIN '.$db->prefix.'users AS u ON u.id = o.user_id WHERE idle=0 ORDER BY ident', true) or error('Unable to fetch online list', __FILE__, __LINE__, $db->error());
FIND:
while ($pun_user_online = $db->fetch_assoc($result))
{
if ($pun_user_online['user_id'] > 1)
$users[] = "\n\t\t\t\t".'<dd><a href="profile.php?id='.$pun_user_online['user_id'].'">'.pun_htmlspecialchars($pun_user_online['ident']).'</a>';
else
++$num_guests;
}
REPLACE WITH
while ($pun_user_online = $db->fetch_assoc($result))
{
if ($pun_user_online['user_id'] > 1)
{
if ($pun_user_online['status'] > PUN_MOD)
$users[] = "\n\t\t\t\t".'<dd><a href="profile.php?id='.$pun_user_online['user_id'].'">'.pun_htmlspecialchars($pun_user_online['ident']).'</a>';
else
$users[] = "\n\t\t\t\t".'<dd><i><a href="profile.php?id='.$pun_user_online['user_id'].'">'.pun_htmlspecialchars($pun_user_online['ident']).'</a></i>';
}
else
++$num_guests;
}
That will make any mods/admins who are online show up in italics (substitute other HTML for the <i> and </i>s if you wish)
Edit: This is untested, tell me if it works or not
Works great now! Thanks!
PunBB Forums → Feature requests → Styling the onlinenames...
Powered by PunBB, supported by Informer Technologies, Inc.