Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Color All Post Backgrounds of a Usergroup
#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:

<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:

<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:

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

Change the code to:

<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):

.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.
[Image: dehibernate.png]
Reply
#2
I think some things need to be changed:
Shouldn't
<td class="trow2 post_content post{$usergroup['gid']} $unapproved_shade}">
Be
<td class="trow2 post_content post{$usergroup['gid']} {$unapproved_shade}">
And
<div id="pid_{$post['pid']}" class="post_body" post{$usergroup['gid']}>
Should be
<div id="pid_{$post['pid']}" class="post_body post{$usergroup['gid']}">
Reply
#3
:p Some typo. Thanks. Updated. Repped Big Grin
[Image: dehibernate.png]
Reply
#4
Thanks and your welcome. Use the preview feature!Toungue
Reply
#5
how to make the whole postbit coloured of that group

i mean post buttons also how to make it
Reply
#6
If you can get the idea of the trick you can apply the same anywhere in the postbit depending on usergroup.
[Image: dehibernate.png]
Reply
#7
sorry but i still didnt get how i would like to have a small tutorial for this as well
Reply
#8
Just edit the class for the postbit's element. If you had basic HTML/CSS knowledge the tutorial would be enough to help you.
Reply
#9
yeah i did it is working fine now thanks
Reply
#10
(11-19-2013, 10:34 PM)$kull Wrote: yeah i did it is working fine now thanks

How did you do it? To make whole postbit that color?

How to color whole post body?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)