PDA

View Full Version : Custom CSS based on Usergroup?


dotJoel
09-30-2008, 01:42 AM
Hi Guys,

I have a question....

I would like when posts are made from a certain usergroup in the forum that their posts receive a different background to others so that other members can recognise these posts easier.

I understand I need to use an <if> statement to achieve this. I tried:

<if condition="is_member_of($vbulletin->userinfo, 1, 2, 3)"></if>
<td class="postbox" id="td_post_$post[postid]">
<else />
<td class="postbox2" id="td_post_$post[postid]">
</if>

However this only works for the person making the post. It does not change the background for everyone else reading the forum only the individual that made the post can see the difference when they are logged in.

Any help would be great!

Regards,

Joel

dotJoel
10-07-2008, 01:59 PM
* Bump *

Lynne
10-07-2008, 02:37 PM
How about:
<if condition="is_member_of($post, 1, 2, 3)">
<td class="postbox" id="td_post_$post[postid]">
<else />
<td class="postbox2" id="td_post_$post[postid]">
</if>

(Also, did you realize you had an </if> after your conditional on the first line?)

geeklands
10-20-2008, 10:33 AM
This is relevant to my interests,

Is there any full way to do this?

Ive seen it on some company forums.

Lynne
10-20-2008, 02:21 PM
This is relevant to my interests,

Is there any full way to do this?

Ive seen it on some company forums.
Did you try what was posted?

geeklands
10-21-2008, 08:17 PM
Sorry, im not too good with this kind of stuff.

What im after, if the background of the posts of admins, mods and super mods to be a different color from the norm.

the Age Of Conan forum has it, although they wont tell me how :(

Lynne
10-21-2008, 08:30 PM
This is for 3.6.8, change for your own version...

Find this code in your postbit(_legacy) and add this style info into the div tag:
<tr>
<td class="alt1" id="td_post_$post[postid]" style="background-color:yellow">
<!-- message, attachments, sig -->

And, change yellow to the color of your choice. I have not tested this code.

EragonSN
07-07-2009, 03:04 PM
Sorry to bump this old thread, but anyone got any clues to this ?

Lynne
07-07-2009, 03:18 PM
The answer was posted, so I'm not sure what you mean. I think there may even be a mod for this - do a search in "all mods" "titles only" and you may find it.

EragonSN
07-07-2009, 03:21 PM
I'm sorry, but I tried to search, and found nothing, or, maybe I'm just using the wrong key-words.

Either way, the code above doesn't work, the only thing I get to work is to show all member posts with the same color, regardless of their user group.

Lynne
07-07-2009, 06:51 PM
The best way to get help when something "doesn't work" is to post exact what you did so we can see where you went wrong. Please use the code/html/php tags when you post it. And make sure you always tell us the template or hook location when posting code.

EragonSN
07-09-2009, 01:58 PM
I'll just dump my postbit_legacy code part here.
Mind, I use a custom code, coded by someone else, so I have really no clue at all....

Hope this is allowed/alright.

BTW, Lynne, what do you mean by template or hook location ? The path to where the template is located ?

postbit legacy:
$template_hook[postbit_start]
<table id="post$post[postid]" class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="0" border="0" width="100%" align="center">
<tr>
<if condition="$show['announcement']">
<td class="thead" style="font-weight:normal; border: $stylevar[cellspacing]px solid $stylevar[tborder_bgcolor]" colspan="2">
<img class="inlineimg" src="$stylevar[imgdir_statusicon]/post_$post[statusicon].gif" alt="$post[statustitle]" border="0" />
<phrase 1="$post[startdate]" 2="$post[enddate]">$vbphrase[x_until_y]</phrase>
</td>
<else />
<td class="thead" style="font-weight:normal; border: $stylevar[cellspacing]px solid $stylevar[tborder_bgcolor]; border-$stylevar[right]: 0px" $post[scrolltothis]>
<!-- status icon and date -->
<a name="post$post[postid]"><img class="inlineimg" src="$stylevar[imgdir_statusicon]/post_$post[statusicon].gif" alt="$post[statustitle]" border="0" /></a>
$post[postdate]<if condition="!$show['detailedtime']">, $post[posttime]</if>
$post[firstnewinsert]
<!-- / status icon and date -->
</td>
<td class="thead" style="font-weight:normal; border: $stylevar[cellspacing]px solid $stylevar[tborder_bgcolor]; border-$stylevar[left]: 0px" align="$stylevar[right]">
&nbsp;
<if condition="$show['postcount']">#<a href="showpost.php?$session[sessionurl]p=$post[postid]&amp;postcount=$post[postcount]" target="new" rel="nofollow" id="postcount$post[postid]" name="$post[postcount]"><strong>$post[postcount]</strong></a></if>
<if condition="$show['inlinemod']">
<input type="checkbox" name="plist[$postid]" id="plist_$postid" style="vertical-align:middle; padding:0px; margin:0px 0px 0px 5px" value="$post[checkbox_value]" />
</if>
</td>
</if>
</tr>
<tr valign="top">
<if condition="is_member_of($post, 6)">
<td class="postbit" width="175" style="border: $stylevar[cellspacing]px solid $stylevar [tborder_bgcolor]; border-top: 0px; border-bottom: 0px; id="td_post_$post[postid]">
<else />
<td class="alt2" width="175" style="border: $stylevar[cellspacing]px solid $stylevar[tborder_bgcolor]; border-top: 0px; border-bottom: 0px">
</if>

<div id="postmenu_$post[postid]">
<if condition="$show['profile']">
<a class="bigusername" href="member.php?$session[sessionurl]u=$post[userid]">$post[musername]</a>
<script type="text/javascript"> vbmenu_register("postmenu_$post[postid]", true); </script>
<else />
$post[musername]
</if>
</div>

<if condition="$post['usertitle']"><div class="smallfont">$post[usertitle]</div></if>
<if condition="$post['rank']"><div class="smallfont">$post[rank]</div></if>
$template_hook[postbit_userinfo_left]

<if condition="$show['avatar']">
<div class="smallfont">
&nbsp;<br /><a href="member.php?$session[sessionurl]u=$post[userid]"><img src="$post[avatarurl]" $post[avwidth] $post[avheight] alt="<phrase 1="$post[username]">$vbphrase[xs_avatar]</phrase>" border="0" /></a>
</div>
</if>

<div class="smallfont">
&nbsp;<br />
<if condition="$post['joindate']"><div>$vbphrase[join_date]: $post[joindate]</div></if>
<if condition="$post['field2']"><div>$vbphrase[location_perm]: $post[field2]</div></if>
<if condition="$post['age']"><div>$vbphrase[age]: $post[age]</div></if>
<div>
$vbphrase[posts]: $post[posts]
</div>
$template_hook[postbit_userinfo_right_after_posts]
<if condition="$show['infraction']"><div>$vbphrase[infractions]: $post[warnings]/$post[infractions] ($post[ipoints])</div></if>
<if condition="$show['reputation']"><if condition="$show['reppower']">$vbphrase[reppower]: <span id="reppower_$post[postid]_$post[userid]">$post[reppower]</span> </if><div><span id="repdisplay_$post[postid]_$post[userid]">$post[reputationdisplay]</span></div></if>
$template_hook[postbit_userinfo_right]
<div>$post[icqicon] $post[aimicon] $post[msnicon] $post[yahooicon] $post[skypeicon]</div>
</div>

</td>
<if condition="$show['moderated']">
<if condition="is_member_of($post, 6)">
<td class="postbit" id="td_post_$post[postid]" style="border-$stylevar[right]: $stylevar[cellspacing]px solid $stylevar[tborder_bgcolor]">
<else />
<td class="alt2" id="td_post_$post[postid]" style="border-$stylevar[right]: $stylevar[cellspacing]px solid $stylevar[tborder_bgcolor]">
</if>
<else />
<td class="alt1" id="td_post_$post[postid]" style="border-$stylevar[right]: $stylevar[cellspacing]px solid $stylevar[tborder_bgcolor]">
</if>
$template_hook[postbit_messagearea_start]
<if condition="$show['messageicon'] OR $post['title']">
<!-- icon and title -->
<div class="smallfont">
<if condition="$show['messageicon']"><img class="inlineimg" src="$post[iconpath]" alt="$post[icontitle]" border="0" /></if>
<if condition="$post['title']"><strong>$post[title]</strong></if>
</div>
<hr size="1" style="color:$stylevar[tborder_bgcolor]; background-color:$stylevar[tborder_bgcolor]" />
<!-- / icon and title -->
</if>

<!-- message -->
<div id="post_message_$post[postid]">
$ad_location[ad_showthread_firstpost_start]
$post[message]
</div>
<!-- / message -->

<if condition="$show['attachments']">
<!-- attachments -->
<div style="padding:$stylevar[cellpadding]px">

<if condition="$show['thumbnailattachment']">
<fieldset class="fieldset">
<legend>$vbphrase[attached_thumbnails]</legend>
<div style="padding:$stylevar[formspacer]px">
$post[thumbnailattachments]
</div>
</fieldset>
</if>

<if condition="$show['imageattachment']">
<fieldset class="fieldset">
<legend>$vbphrase[attached_images]</legend>
<div style="padding:$stylevar[formspacer]px">
$post[imageattachments]
</div>
</fieldset>
</if>

<if condition="$show['imageattachmentlink']">
<fieldset class="fieldset">
<legend>$vbphrase[attached_images]</legend>
<table cellpadding="0" cellspacing="$stylevar[formspacer]" border="0">
$post[imageattachmentlinks]
</table>
</fieldset>
</if>

<if condition="$show['otherattachment']">
<fieldset class="fieldset">
<legend>$vbphrase[attached_files]</legend>
<table cellpadding="0" cellspacing="$stylevar[formspacer]" border="0">
$post[otherattachments]
</table>
</fieldset>
</if>

<if condition="$show['moderatedattachment']">
<fieldset class="fieldset">
<legend>$vbphrase[attachments_pending_approval]</legend>
<table cellpadding="0" cellspacing="$stylevar[formspacer]" border="0">
$post[moderatedattachments]
</table>
</fieldset>
</if>

</div>
<!-- / attachments -->
</if>

$template_hook[postbit_signature_start]
$ad_location[ad_showthread_firstpost_sig]

<if condition="$post['signature']">
<!-- sig -->
<div>
__________________<br />
$post[signature]
</div>
<!-- / sig -->
</if>

$template_hook[postbit_signature_end]

<if condition="$show['postedited']">
<!-- edit note -->
<div class="smallfont">
<hr size="1" style="color:$stylevar[tborder_bgcolor]; background-color:$stylevar[tborder_bgcolor]" />
<em>
<if condition="$show['postedithistory']">
<phrase 1="$post[edit_username]" 2="$post[edit_date]" 3="$post[edit_time]" 4="posthistory.php?$session[sessionurl]p=$post[postid]">$vbphrase[last_edited_link_by_x_on_y_at_z_postid]</phrase>
<else />
<phrase 1="$post[edit_username]" 2="$post[edit_date]" 3="$post[edit_time]">$vbphrase[last_edited_by_x_on_y_at_z]</phrase>
</if>
<if condition="$post['edit_reason']">
$vbphrase[reason]: $post[edit_reason]
</if>
</em>
</div>
<!-- / edit note -->
</if>

</td>
</tr>
<tr>
<if condition="is_member_of($post, 6)">
<td class="postbit" style="border: $stylevar[cellspacing]px solid $stylevar[tborder_bgcolor]; border-top: 0px">
<else />
<td class="alt2" style="border: $stylevar[cellspacing]px solid $stylevar[tborder_bgcolor]; border-top: 0px"></if>
$post[onlinestatus]
<if condition="$show['reputationlink']">
<span id="reputationmenu_$post[postid]"><a href="reputation.php?$session[sessionurl]p=$post[postid]" rel="nofollow" id="reputation_$post[postid]"><img class="inlineimg" src="$stylevar[imgdir_button]/reputation.gif" alt="<phrase 1="$post[username]">$vbphrase[add_to_xs_reputation]</phrase>" border="0" /></a></span>
<if condition="$show['popups']"><script type="text/javascript"> vbrep_register("$post[postid]")</script></if>
</if>
<if condition="$show['infractionlink']"><a href="infraction.php?$session[sessionurl]do=report&amp;p=$post[postid]" rel="nofollow"><img class="inlineimg" src="$stylevar[imgdir_button]/infraction.gif" alt="<phrase 1="$post[username]">$vbphrase[add_infraction_for_x]</phrase>" border="0" /></a></if>
<if condition="$show['reportlink']"><a href="report.php?$session[sessionurl]p=$post[postid]" rel="nofollow"><img class="inlineimg" src="$stylevar[imgdir_button]/report.gif" alt="$vbphrase[report_bad_post]" border="0" /></a></if>
$post[iplogged]
&nbsp;
</td>
<if condition="$show['moderated']">
<td class="alt2" align="$stylevar[right]" style="border: $stylevar[cellspacing]px solid $stylevar[tborder_bgcolor]; border-$stylevar[left]: 0px; border-top: 0px">
<else />
<td class="alt1" align="$stylevar[right]" style="border: $stylevar[cellspacing]px solid $stylevar[tborder_bgcolor]; border-$stylevar[left]: 0px; border-top: 0px">
</if>
<!-- controls -->
<if condition="$post['editlink']">
<img style="display: none" id="progress_$postid" src="$stylevar[imgdir_misc]/progress.gif" alt="$vbphrase[loading_editor_please_wait]" />
<a href="$post[editlink]" name="vB::QuickEdit::$post[postid]"><img src="$stylevar[imgdir_button]/edit.gif" alt="$vbphrase[edit_delete_message]" border="0" /></a>
</if>
<if condition="$post['forwardlink']">
<a href="$post[forwardlink]"><img src="$stylevar[imgdir_button]/forward.gif" alt="$vbphrase[forward_message]" border="0" /></a>
</if>
<if condition="$post['replylink']">
<a href="$post[replylink]" rel="nofollow"><img src="$stylevar[imgdir_button]/<if condition="$post['forwardlink']">reply_small<else />quote</if>.gif" alt="$vbphrase[reply_with_quote]" border="0" /></a>
</if>
<if condition="$show['multiquote_post']">
<a href="$post[replylink]" rel="nofollow" onclick="return false"><img src="$stylevar[imgdir_button]/multiquote_<if condition="$show['multiquote_selected']">on<else />off</if>.gif" alt="$vbphrase[multi_quote_this_message]" border="0" id="mq_$post[postid]" /></a>
</if>
<if condition="$show['quickreply'] AND !$show['threadedmode']">
<a href="$post[replylink]" rel="nofollow" id="qr_$post[postid]" onclick="return false"><img src="$stylevar[imgdir_button]/quickreply.gif" alt="$vbphrase[quick_reply_to_this_message]" border="0" /></a>
</if>
<if condition="$show['moderated']">
<img src="$stylevar[imgdir_misc]/moderated.gif" alt="$vbphrase[moderated_post]" border="0" />
</if>
<if condition="$show['spam']">
<img src="$stylevar[imgdir_misc]/spam_detected.png" alt="$vbphrase[spam_post]" border="0" />
</if>
<if condition="$show['deletedpost']">
<if condition="$show['managepost']">
<a href="postings.php?$session[sessionurl]do=managepost&amp;p=$post[postid]"><img src="$stylevar[imgdir_misc]/trashcan.gif" alt="$vbphrase[manage]" border="0" /></a>
<else />
<img src="$stylevar[imgdir_misc]/trashcan.gif" alt="$vbphrase[deleted_post]" border="0" />
</if>
</if>
<if condition="$show['redcard']">
<a href="infraction.php?$session[sessionurl]do=view&amp;p=$post[postid]"><img src="$stylevar[imgdir_button]/redcard.gif" alt="$vbphrase[received_infraction]" border="0" /></a>
<else />
<if condition="$show['yellowcard']">
<a href="infraction.php?$session[sessionurl]do=view&amp;p=$post[postid]"><img src="$stylevar[imgdir_button]/yellowcard.gif" alt="$vbphrase[received_warning]" border="0" /></a>
</if>
</if>
$template_hook[postbit_controls]
<!-- / controls -->
</td>
</tr>
</table>
$template_hook[postbit_end]

<!-- post $post[postid] popup menu -->
<div class="vbmenu_popup" id="postmenu_$post[postid]_menu" style="display:none">
<table cellpadding="4" cellspacing="1" border="0">
<tr>
<td class="thead">$post[username]</td>
</tr>
<if condition="$show['profile']">
<tr><td class="vbmenu_option"><a href="member.php?$session[sessionurl]u=$post[userid]">$vbphrase[view_public_profile]</a></td></tr>
</if>
<if condition="$show['pmlink']">
<tr><td class="vbmenu_option"><a href="private.php?$session[sessionurl]do=newpm&amp;u=$post[userid]" rel="nofollow"><phrase 1="$post[username]">$vbphrase[send_private_message_to_x]</phrase></a></td></tr>
</if>
<if condition="$show['emaillink']">
<tr><td class="vbmenu_option"><a href="sendmessage.php?$session[sessionurl]do=mailmember&amp;u=$post[userid]" rel="nofollow"><phrase 1="$post[username]">$vbphrase[send_email_to_x]</phrase></a></td></tr>
</if>
<if condition="$show['homepage']">
<tr><td class="vbmenu_option"><a href="$post[homepage]"><phrase 1="$post[username]">$vbphrase[visit_xs_homepage]</phrase></a></td></tr>
</if>
<if condition="$show['search']">
<tr><td class="vbmenu_option"><a href="search.php?$session[sessionurl]do=finduser&amp;u=$post[userid]" rel="nofollow"><phrase 1="$post[username]">$vbphrase[find_more_posts_by_x]</phrase></a></td></tr>
</if>
<if condition="$post['userid'] AND $show['member']">
<tr><td class="vbmenu_option"><a href="profile.php?$session[sessionurl]do=addlist&amp;userlist=buddy&amp;u=$post[userid]"><phrase 1="$post[username]">$vbphrase[add_x_to_contacts]</phrase></a></td></tr>
</if>
$template_hook[postbit_user_popup]
</table>
</div>
<!-- / post $post[postid] popup menu -->

Lynne
07-09-2009, 02:09 PM
You didn't show the code you tried at all. Nowhere in there do I see an added condition based on usergroup for the background. I can't tell what you did wrong if you don't post what you did.

EragonSN
07-09-2009, 02:14 PM
Oh shit, wrong piece of code.

Let me update it.

--------------- Added 1247154163 at 1247154163 ---------------

Updated, also marked the areas I've changed with red color.

CSS .postbit is simply background-color.

I've gotten it half-way working now, only part missing is the background-color for the post itself, user-area and all those mini buttons (report, etc) are showing correctly.

I got a bit confused at this part:

<if condition="$show['moderated']">
<td class="alt2" id="td_post_$post[postid]" style="border-$stylevar[right]: $stylevar[cellspacing]px solid $stylevar[tborder_bgcolor]">
<else />
<td class="alt1" id="td_post_$post[postid]" style="border-$stylevar[right]: $stylevar[cellspacing]px solid $stylevar[tborder_bgcolor]">
</if>

EragonSN
07-11-2009, 09:28 AM
Anyone able to give me a hand ? I can't seem to find the correct spot to include the code

Lynne
07-11-2009, 02:21 PM
What is the result of the code you posted above (a link to a page where this should be working would be useful)? It's hard to help when you didn't say what is wrong. And, check your page source to see what is in there.

$show['moderatored'] has to do with whether a post is a moderated post to show just to the moderators.

miner
07-12-2009, 04:07 AM
Check this https://vborg.vbsupport.ru/showthread.php?t=203850

EragonSN
07-12-2009, 09:05 AM
What is the result of the code you posted above (a link to a page where this should be working would be useful)? It's hard to help when you didn't say what is wrong. And, check your page source to see what is in there.

$show['moderatored'] has to do with whether a post is a moderated post to show just to the moderators.
Here's the link to the website: http://l2-lastbattle.com/forum/showthread.php?t=2

I've tried so much, but I have honestly not much of a clue on where to place the codebit.


Check this https://vborg.vbsupport.ru/showthread.php?t=203850

I've been using that, it only works for the user info section (avatar, name, posts, etc) but not for the postbit itself.

S H ! F T
07-12-2009, 10:45 AM
Try this :

first open this file

forumdisplay.php

find

// Soft Deleted Thread

add above

// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ADD BY MGHOOL - A
$Tu = $vbulletin->db->query_first_slave("SELECT usergroupid FROM " . TABLE_PREFIX . "user WHERE userid = " . $thread['postuserid'] . " LIMIT 1");
$To = $vbulletin->usergroupcache["" . $Tu['usergroupid'] . ""]['opentag'];
$Tc = $vbulletin->usergroupcache["" . $Tu['usergroupid'] . ""]['closetag'];
$thread['threadtitle'] = $To . $thread['threadtitle'] . $Tc;
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ADD BY MGHOOL - V

this is for all groups that you have

if you want to do this for Certain groups

add this code

// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ADD BY MGHOOL - A $Tx = '6'; $Tu = $vbulletin->db->query_first_slave("SELECT usergroupid FROM " . TABLE_PREFIX . "user WHERE userid = " . $thread['postuserid'] . " LIMIT 1"); if (@in_array($Tu['usergroupid'], @preg_split('#\s*,\s*#s', $Tx, -1, @PREG_SPLIT_NO_EMPTY))) { $To = $vbulletin->usergroupcache["" . $Tu['usergroupid'] . ""]['opentag']; $Tc = $vbulletin->usergroupcache["" . $Tu['usergroupid'] . ""]['closetag']; $thread['threadtitle'] = $To . $thread['threadtitle'] . $Tc; } // @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ADD BY MGHOOL - V



Notice: you need to change number (6) to the ID number of the group you want .. use (,) if you want to do it on Different groups

Save and Upload the file

-----------------

Then

open this file

clientscript/vbulletin_ajax_threadslist.js

find

this.inputobj.style.width = Math.max(this.linkobj.offsetWidth, 250) + 'px';

above that add this code

// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ADD BY MGHOOL - A this.inputobj.maxLength = this.inputobj.maxLength + 85; // @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ADD BY MGHOOL - V



in the same file

find

this.inputobj.title = this.inputobj.value;

add above

// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ADD BY MGHOOL - A this.inputobj.value = this.inputobj.value.replace(/\<(.*?)\>/g, ''); // @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ADD BY MGHOOL - V



Save the file and Upload it

That's will be all

Lynne
07-12-2009, 02:34 PM
Try this instead of what you have:
<if condition="$show['moderated']">
<td class="alt2" id="td_post_$post[postid]" style="border-$stylevar[right]: $stylevar[cellspacing]px solid $stylevar[tborder_bgcolor]">
<else />
<if condition="is_member_of($post, 6)">
<td class="postbit" id="td_post_$post[postid]" style="border-$stylevar[right]: $stylevar[cellspacing]px solid $stylevar[tborder_bgcolor]">
<else />
<td class="alt1" id="td_post_$post[postid]" style="border-$stylevar[right]: $stylevar[cellspacing]px solid $stylevar[tborder_bgcolor]">
</if>
</if>