PDA

View Full Version : thread title color by usergroup


Hawk7173
11-04-2010, 12:28 AM
I picked up a small mod here on the forum that changes a single assigned user's thread title color.........as follows


if ($thread['postuserid'] == 3975) {$thread['threadtitle'] = '<span style="color: #8B0000;">' . $thread['threadtitle'] . '</span>';}

However, I would like to assign a color to a specific usergroup rather than a single user.

What change would I need to make in order to do so?

Thanks in advance! Tony

kh99
11-04-2010, 01:35 AM
<span style="text-decoration: line-through">I think you might be able to use...</span>

I take it back - posts have the user info with them, but it doesn't look like $thread does.

Lynne
11-04-2010, 01:54 AM
You'll have to write a plugin to hook into the thread query (forumdisplay_query) and JOIN with the user table in order to get the postusers usergroupid. Then you'd be able to use $thread['usergroupid'] in the template.

Hawk7173
11-04-2010, 02:01 AM
Thanks, But that something that's a bit much over my head:(:(:(

kh99
11-04-2010, 07:53 AM
Try this: create a new plugin using hook forumdisplay_query (make up a title and remember to check "Yes" next to "Plugin is Active", don't worry about the other fields), and use this for the code:


$hook_query_fields .= ', user.userid, user.usergroupid, user.membergroupids ';
$hook_query_joins .= 'LEFT JOIN ' . TABLE_PREFIX . 'user AS user ON (user.userid = postuserid) ';


//


then in your other code use something like:


if (is_member_of($thread, gid1, gid2, ...)) {$thread['threadtitle'] = '<span style="color: #8B0000;">' . $thread['threadtitle'] . '</span>';}


(of course you want to use actual group id numbers in place of gid1, gid2, etc).

Hawk7173
11-04-2010, 05:26 PM
I created the plugin as written and changed the second plugin and it does not work.

just to make sure I did this correctly, the original plugin I did was in "thread_bit" should that be changed to "thread_query", or should that remain the same?

Lynne
11-04-2010, 06:03 PM
We need to know *exactly* what you used - write the code and state the hook location for each plugin.

Hawk7173
11-04-2010, 06:23 PM
Went back and double checked and left something out. All is good and thank you all for the help!!!

--------------- Added 1288900078 at 1288900078 ---------------

Is there a way of fixing it so the usernames of those in the same usergroup show the same color under the thread title on the index pages?

kh99
11-04-2010, 11:32 PM
Is there a way of fixing it so the usernames of those in the same usergroup show the same color under the thread title on the index pages?

It's possible but not that easy. You'd have to do a database query to get the user info.