View Full Version : Trying to color everything, LOL
Okay, well im trying to colorize the thread starter in forumdisplay based on the usergroup that member is in. The original code in forumdisplay.php is this:
# if ($thread['postuserid']) {
# $thread['postedby'] = "<a href=\"member.php?s=$session[sessionhash]&action=getinfo&userid=$thread[postuserid]\">$thread[postusername]</a>";
# } else {
# $thread['postedby'] = $thread[postusername];
# }I commented that out, and using the utmost BASIC of my php knoleadge replaced it with this code:if ($userinfo['usergroupid'] == '6') {
$thread['postedby'] .= "<a href='member.php?s=$session[sessionhash]&action=getinfo&userid=$thread[postuserid]'><font color='#cc0000'><b><i>$thread[postusername]</i></b></font></a>";
}
else if ($userinfo['usergroupid'] == '7') {
$thread['postedby'] .= "<a href='member.php?s=$session[sessionhash]&action=getinfo&userid=$thread[postuserid]'><font color='green'><b>$thread[postusername]</b></font></a>";
}
else if ($userinfo['usergroupid'] == '5') {
$thread['postedby'] .= "<a href='member.php?s=$session[sessionhash]&action=getinfo&userid=$thread[postuserid]'><font color='green'><b>$thread[postusername]</b></font></a>";
}
else {
$thread['postedby'] .= "<a href='member.php?s=$session[sessionhash]&action=getinfo&userid=$thread[postuserid]'><font color='blue'>$thread[postusername]</font></a>";
}
but this only makes all the usernames blue, no matter what group they are in.. what am I doing wrong, a little kick in the right direction would be steller, thanks :)
-myles
ZiRu$
08-20-2002, 02:38 AM
Originally posted by snyx
if ($userinfo['usergroupid'] == '6') {
$thread['postedby'] .= "<a href='member.php?s=$session[sessionhash]&action=getinfo&userid=$thread[postuserid]'><font color='#cc0000'><b><i>$thread[postusername]</i></b></font></a>";
}
else if ($userinfo['usergroupid'] == '7') {
$thread['postedby'] .= "<a href='member.php?s=$session[sessionhash]&action=getinfo&userid=$thread[postuserid]'><font color='green'><b>$thread[postusername]</b></font></a>";
}
else if ($userinfo['usergroupid'] == '5') {
$thread['postedby'] .= "<a href='member.php?s=$session[sessionhash]&action=getinfo&userid=$thread[postuserid]'><font color='green'><b>$thread[postusername]</b></font></a>";
}
else {
$thread['postedby'] .= "<a href='member.php?s=$session[sessionhash]&action=getinfo&userid=$thread[postuserid]'><font color='blue'>$thread[postusername]</font></a>";
}
[/php]
TRY THIS.......i dont know ++++ so back it up....
if ($loggedin['usergroupid'] == 6 and $highlightadmin) {
$username = "<b><i><font color=red>$loggedin[username]</font></i></b>"; // Color for Admin
} else if (($loggedin['usergroupid'] == 7) and $highlightadmin) {
$username = "<b><font color=darkred>$loggedin[username]</font></b>"; // Color for Supermod
} else if (($mod["$userid"]) and $highlightadmin) {
$username = "<b><font color=green>$loggedin[username]</font></b>"; // Color for Mod
} else {
$username = "<font color=blue>$loggedin[username]</font>"; // Color for normal Member or "Highlight Admin" is turned of
}
and change the values...usergroup ids, colors and ++++
grrrrrr no that didnt work.. huh
is there anyway I could establish the usercolor some other way.. and call it into the code.. like..
# if ($thread['postuserid']) {
# $thread['postedby'] = "<a href=\"member.php?s=$session[sessionhash]&action=getinfo&userid=$thread[postuserid]\">$thread[SPECIALpostusername]</a>";
# } else {
# $thread['postedby'] = $thread[SPECIALpostusername];
# }
ZiRu$
08-20-2002, 01:10 PM
why dont you install the colored ONLINE USERS Hack?
is that what your trying to do? or in the postbit too?
in forumdisplay.. so were talkin somthing completely different!
I tried all the whos online hacks, and users browsing format ;)
Xenon
08-20-2002, 07:56 PM
it can't show another color than blue, becaue your variable $userinfo isn't defined in forumdisplay, so the script allways runs the else condition.
you have to add a query to get $userinfo, or it would be impossible:
if ($thread['postuserid']) {
$userinfo=$DB_site->query_first("SELECT username,usergroupid FROM user WHERE userid=".$thread['postuserid']);
if($userinfo['usergroupid']==6) $color="red";
elseif ($userinfo['usergroupid']==5) $color="green";
else $color="blue";
$thread['postedby'] = "<font color=".$color."><a href=\"member.php?s=$session[sessionhash]&action=getinfo&userid=$thread[postuserid]\">$userinfo[username]</a></font>";
} else {
$thread['postedby'] = $thread[postusername];
}
i know the code is optimizable, because it added a lot of queries, but it should work..
EEP! 57 queries..
but yeah thx for the shot, but im still not getting any colorednames.. huh they just look normal as if the color wasnt working at all.
uhhhhh, damn. :(
Xenon I was wrong, your code was right, you html just off, to colorize links you need to include the font next to the actaully text inside the hyperlink... I tweaked the code to get what I like, thx man, and thx for ur guys help :)
if ($thread['postuserid']) {
$userinfo=$DB_site->query_first("SELECT username,usergroupid FROM user WHERE userid=".$thread['postuserid']);
if($userinfo['usergroupid']==6) $special="<font color=#cc0000><b><i>";
elseif ($userinfo['usergroupid']==5) $special="<font color=green><b>";
elseif ($userinfo['usergroupid']==7) $special="<font color=green><b>";
else $special="<font color=blue>";
$thread['postedby'] = "<a href=\"member.php?s=$session[sessionhash]&action=getinfo&userid=$thread[postuserid]\">$special $userinfo[username]</a></font>";
-Myles
Xenon
08-21-2002, 03:58 PM
you can decreasing the ammount of queries by adding some sort of hashing:
instead of$userinfo=$DB_site->query_first("SELECT username,usergroupid FROM user WHERE userid=".$thread['postuserid']);
if($userinfo['usergroupid']==6) $special="<font color=#cc0000><b><i>";
elseif ($userinfo['usergroupid']==5) $special="<font color=green><b>";
elseif ($userinfo['usergroupid']==7) $special="<font color=green><b>";
try to use this:
if(!isset($userinfo[$thread[postuserid]])) $userinfo[$thread[postuserid]]=$DB_site->query_first("SELECT username,usergroupid FROM user WHERE userid=".$thread['postuserid']);
if($userinfo[$thread[postuserid]]['usergroupid']==6) $special="<font color=#cc0000><b><i>";
elseif ($userinfo[$thread[postuserid]]['usergroupid']==5) $special="<font color=green><b>";
elseif ($userinfo[$thread[postuserid]]['usergroupid']==7) $special="<font color=green><b>";
should work, but not tested ;)
Xenon
08-21-2002, 04:25 PM
ignore that, why not just using a JOIN query ;)
just find:$threads=$DB_site->query("
SELECT $dotuserid $votequery ".iif($foruminfo[allowicons],'icon.title as icontitle,icon.iconpath,','')."
thread.threadid,thread.title,lastpost, forumid,pollid,open,replycount,postusername,postus erid,
lastposter,thread.dateline,views,thread.iconid,not es,thread.visible,sticky,votetotal,attach
FROM thread
".iif($foruminfo[allowicons],'LEFT JOIN icon ON (icon.iconid = thread.iconid)','')."
$dotjoin
WHERE $threadids
ORDER BY sticky DESC, $sortfield $sqlsortorder
");
and replace it with:
$threads=$DB_site->query("
SELECT $dotuserid $votequery ".iif($foruminfo[allowicons],'icon.title as icontitle,icon.iconpath,','')."
thread.threadid,thread.title,thread.lastpost, forumid,pollid,open,replycount,postusername,postus erid,
lastposter,user.usergroupid,thread.dateline,views, thread.iconid,notes,thread.visible,sticky,votetota l,attach
FROM thread
".iif($foruminfo[allowicons],'LEFT JOIN icon ON (icon.iconid = thread.iconid)','')."
$dotjoin
LEFT JOIN user ON (thread.postuserid = user.userid)
WHERE $threadids
ORDER BY sticky DESC, $sortfield $sqlsortorder
");
then you could use $thread[usergroupid] in your if construction and save a lot of extra queries ;)
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.