MyBB Tutorials

Color All Post Backgrounds of a Usergroup

Submitted by Blowjob, , Thread ID: 627

Thread Closed
Blowjob
Closed Account
Level:
0
Reputation:
26
Posts:
2.16K
Likes:
189
Credits:
2.53K
23-01-2015, 07:01 AM
#1
This tutorial is for those who want some specific usergroup's posts be different from the others. Like say all moderators' post background to be some different color. We can do it without using any plugin. Let's discuss about that trick today.

First we have to add a special class to our postbit templates to override the default post colors. For that open the template:

ACP > Templates & Styles > Templates > [Theme Name] Templates > Postbit Templates > postbit

and find:


Code:
<td class="trow2 post_content {$unapproved_shade}">

Now we have to add our special class post{$usergroup['gid']} to it. So, change the code to:


Code:
<td class="trow2 post_content post{$usergroup['gid']} {$unapproved_shade}">

Note that: You have to place the class
a) after class 'trow2' else the 'trow2' background color will govern.
b) before class'{$unapproved_shade}' so that Unapproved post's color can lead over any user's post.

Do the same thing with postbit_classic template. Open:

ACP > Templates & Styles > Templates > [Theme Name] Templates > Postbit Templates > postbit_classic

and find:


Code:
<div id="pid_{$post['pid']}" class="post_body">

Change the code to:


Code:
<div id="pid_{$post['pid']}" class="post_body post{$usergroup['gid']}">

Now the CSS, main trick part. Our dynamic class 'post{$usergroup['gid']}' will change at runtime based on group ID. ie. for all the posts of admins (default group ID is 4) it will be post4, for all the posts of members (default group ID is 2) it will be post2

So, as we said, if we want to target the specific group, for our example, say Moderators (default group ID is 6) we will declare our CSS class as .post6

Now, open your global.css and add at the end (or any suitable location):


Code:
.post6 { background: #FDB5FF; }

and save global.css.

Now the background of all posts made by any Moderator is a decent light pink.
We can change post backgrounds for as many usergroups as we wish using this trick, only we need to know the target group ID and change the number at the end of the class in css as per that group ID.

RE: Color All Post Backgrounds of a Usergroup

AndresXZ09
Closed Account
Level:
0
Reputation:
30
Posts:
1.22K
Likes:
139
Credits:
1.51K
27-01-2015, 04:06 AM
#2
Your tutorials are AWESOME

RE: Color All Post Backgrounds of a Usergroup

Calibre
Member
Level:
0
Reputation:
5
Posts:
115
Likes:
10
Credits:
128
27-01-2015, 04:09 AM
#3
This changes the whole post's text that is typed by the certain group member?
Impress the best, stand out from the rest.

RE: Color All Post Backgrounds of a Usergroup

Blowjob
Closed Account
Level:
0
Reputation:
26
Posts:
2.16K
Likes:
189
Credits:
2.53K
OP
27-01-2015, 04:36 AM
#4
27-01-2015, 04:09 AM
Calibre Wrote:
This changes the whole post's text that is typed by the certain group member?

Background*

example: http://community.mybb.com/thread-165884-...pid1133741

RE: Color All Post Backgrounds of a Usergroup

Calibre
Member
Level:
0
Reputation:
5
Posts:
115
Likes:
10
Credits:
128
27-01-2015, 09:52 AM
#5
Oh now I get it, still a great addition to the usergroups.
Impress the best, stand out from the rest.

RE: Color All Post Backgrounds of a Usergroup

AndresXZ09
Closed Account
Level:
0
Reputation:
30
Posts:
1.22K
Likes:
139
Credits:
1.51K
28-01-2015, 09:26 PM
#6
Question, I don't have to add the Group ID to any part of the code? Just copy and paste it?

And, is it possible to add it to multiple user groups? I want to color the posts of administrators and moderators

RE: Color All Post Backgrounds of a Usergroup

Blowjob
Closed Account
Level:
0
Reputation:
26
Posts:
2.16K
Likes:
189
Credits:
2.53K
OP
30-01-2015, 12:45 AM
#7
28-01-2015, 09:26 PM
AndresXZ09 Wrote:
Question, I don't have to add the Group ID to any part of the code? Just copy and paste it?

And, is it possible to add it to multiple user groups? I want to color the posts of administrators and moderators

1. what?

2. yes :yus:

RE: Color All Post Backgrounds of a Usergroup

AndresXZ09
Closed Account
Level:
0
Reputation:
30
Posts:
1.22K
Likes:
139
Credits:
1.51K
30-01-2015, 03:57 AM
#8
30-01-2015, 12:45 AM
Hug Wrote:
28-01-2015, 09:26 PM
AndresXZ09 Wrote:
Question, I don't have to add the Group ID to any part of the code? Just copy and paste it?

And, is it possible to add it to multiple user groups? I want to color the posts of administrators and moderators

1. what?

2. yes :yus:

nvm.

What's the code for multiple groups?

RE: Color All Post Backgrounds of a Usergroup

Blowjob
Closed Account
Level:
0
Reputation:
26
Posts:
2.16K
Likes:
189
Credits:
2.53K
OP
01-02-2015, 08:28 PM
#9
01-02-2015, 10:31 AM
Vstrech Wrote:
This is nice and all but I use this

<span style="background: url(http://i.imgur.com/7F70N.gif) no-repeat scroll 0% 0% transparent; color: red; text-shadow: 0px 0px 5px rgb(70, 135, 134);">{username}</span>

I don't recommend that but yeah you can use it if you want

RE: Color All Post Backgrounds of a Usergroup

AndresXZ09
Closed Account
Level:
0
Reputation:
30
Posts:
1.22K
Likes:
139
Credits:
1.51K
01-02-2015, 10:37 PM
#10
01-02-2015, 08:28 PM
Hug Wrote:
01-02-2015, 10:31 AM
Vstrech Wrote:
This is nice and all but I use this

<span style="background: url(http://i.imgur.com/7F70N.gif) no-repeat scroll 0% 0% transparent; color: red; text-shadow: 0px 0px 5px rgb(70, 135, 134);">{username}</span>

I don't recommend that but yeah you can use it if you want

Hug can you tell me what is the code for multiple user groups?

Users browsing this thread: 1 Guest(s)