Gossamer Forum
Home : Products : Gossamer Forum : Development, Plugins and Globals :

Re: [Ian] Coloring of usernames

Quote Reply
Re: [Ian] Coloring of usernames In reply to
I have this almost working now based on groups with the folowing handly little function (Thanks to the other Jason):

Code:


sub colorize_user {
my ($username, $user_id) = @_;

# if no user_id was passed look it up
if (!$user_id and $username) {
$user_id = $DB->table("User")->select(user_id => {user_username => $username})->fetchrow;
}

# now color
if ($user_id and $username) {
# Color OSI Staff group
if ($DB->table("UserGroup")->count({user_id_fk => $user_id, group_id_fk => 42 })) {
$username = qq|<span style="color:#990000; font:bold">| . GT::CGI::html_escape($username). qq|</span>|;
}
# Color Moderator group
elsif ($DB->table("UserGroup")->count({user_id_fk => $user_id, group_id_fk => 43 })) {
$username = qq|<span style="color:#009900; font:bold">| . GT::CGI::html_escape($username). qq|</span>|;
}
}
return "$username";
}


In my templates I use it like this:

<%colorize_user($forum_last_poster)%>

Problem is the html generated by the sub gets escaped before it's printed (< changes to &lt; and so on). So <span style="color:blah">User</span> just prints out instead of actually affecting the color of the text.

How do I keep this from happening?
Subject Author Views Date
Thread Coloring of usernames jzahn 3435 Sep 4, 2002, 1:43 PM
Thread Re: [jzahn] Coloring of usernames
sangiro 3372 Sep 5, 2002, 2:32 AM
Thread Re: [sangiro] Coloring of usernames
jzahn 3342 Sep 6, 2002, 9:31 AM
Thread Re: [jzahn] Coloring of usernames
jzahn 3355 Sep 6, 2002, 9:59 AM
Thread Re: [jzahn] Coloring of usernames
Jag 3335 Sep 6, 2002, 10:21 AM
Post Re: [Jag] Coloring of usernames
jzahn 3340 Sep 6, 2002, 1:03 PM
Thread Re: [jzahn] Coloring of usernames
Ian 3308 Sep 7, 2002, 8:02 AM
Post Re: [Ian] Coloring of usernames
jzahn 3260 Sep 13, 2002, 12:21 PM