News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

New Forum Colors

Started by float4life, January 14, 2012, 07:44:51 PM

Previous topic - Next topic

float4life

Yes. I don't want anything to be strict. If someone wants to use a color, let them. I just want to have a default color for each group, so that group doesn't have to change it manually every single time.

Arantor

And how often are you likely to want to change the default colours? (I'm thinking about keeping it very simple internally to minimise the changes to SMF, which means any changes will be done at the code level, rather than a nice UI somewhere.)

Also, what colours, what user group ids are we talking about? (Group 1 is admins, if that helps.)

float4life

Quote from: arrowtotheknee on January 14, 2012, 09:16:06 PM
And how often are you likely to want to change the default colours? (I'm thinking about keeping it very simple internally to minimise the changes to SMF, which means any changes will be done at the code level, rather than a nice UI somewhere.)

Also, what colours, what user group ids are we talking about? (Group 1 is admins, if that helps.)
Well honestly, I'm not sure about the IDs. I've redesigned my groups, and have a bunch of new ones.
Colors though:
Admin - #e4d64d
Moderator - #bf22ca
Developer - #FF0000
Regular Member - Doesn't matter, I guess white? #FFF000

Arantor

Well, the groups, you can find out from the admin panel. Go into the manage membergroups bit, and where you see the 'Modify' link to change the groups, the link will look like http://yoursite/index.php?action=admin;area=membergroups;sa=edit;group=1

The number on the end (group=1) is the group id, in this case it's the admin group, which is group 1.

As for doing the rest of the work, it's not much more complex than this. In Sources/Display.php, find this code:
// Run BBC interpreter on the message.
$message['body'] = parse_bbc($message['body'], $message['smileys_enabled'], $message['id_msg']);


To make it work as intended, add this code in before it:
$colours = array(
1 => '#e3d64d',
2 => '#bf22ca',
0 => '#fff000',
);

if (isset($colours[$memberContext[$message['id_member']]['group_id']]))
$message['body'] = '[color=' . $colours[$memberContext[$message['id_member']]['group_id']] . ']' . $message['body'] . '[/color]';


All it does is magically insert the right color bbc in front and at the end of the post if it's the right group.

A couple of things to be aware of:
* The number used in the left of the $colours bit is the group id. I've put in 1 for admins and 2 for moderators (because 2 is the global moderator group normally)
* Post count groups are not included; 0 is the group for regular members not in a normal member group
* Moderators are handled a bit differently internally; pure board moderators will not be considered by this code (because their primary member group is not 3, which is the special group for board-only moderators)

If a group doesn't have any rules, no colour override will be used (so you don't have to have a colour for every group and can safely ignore regular members if you like.

float4life

Quote from: Arantor on January 14, 2012, 10:57:26 PM
Well, the groups, you can find out from the admin panel. Go into the manage membergroups bit, and where you see the 'Modify' link to change the groups, the link will look like http://yoursite/index.php?action=admin;area=membergroups;sa=edit;group=1

The number on the end (group=1) is the group id, in this case it's the admin group, which is group 1.

As for doing the rest of the work, it's not much more complex than this. In Sources/Display.php, find this code:
// Run BBC interpreter on the message.
$message['body'] = parse_bbc($message['body'], $message['smileys_enabled'], $message['id_msg']);


To make it work as intended, add this code in before it:
$colours = array(
1 => '#e3d64d',
2 => '#bf22ca',
0 => '#fff000',
);

if (isset($colours[$memberContext[$message['id_member']]['group_id']]))
$message['body'] = '[color=' . $colours[$memberContext[$message['id_member']]['group_id']] . ']' . $message['body'] . '[/color]';


All it does is magically insert the right color bbc in front and at the end of the post if it's the right group.

A couple of things to be aware of:
* The number used in the left of the $colours bit is the group id. I've put in 1 for admins and 2 for moderators (because 2 is the global moderator group normally)
* Post count groups are not included; 0 is the group for regular members not in a normal member group
* Moderators are handled a bit differently internally; pure board moderators will not be considered by this code (because their primary member group is not 3, which is the special group for board-only moderators)

If a group doesn't have any rules, no colour override will be used (so you don't have to have a colour for every group and can safely ignore regular members if you like.

Sorry about this LATE reply, but I'm using this system again and I've come across a problem. Whenever a certain group posts it shows their group color, but if there happens to be a list of some sort inside of that post, it will stop coloring anything from that bullet to the end of the post. It also shows the closing end of the color code ([/code]). If anyone knows how to make it color the bullets/numbers and the items in that list, please let me know.

float4life

Bump. I still need help with this problem.

Advertisement: