View Full Version : Custom Field in Postbit_legacy
J. Schultz
07-14-2011, 01:39 AM
Hi all,
I read through Lynne's great article on adding custom fields to the postbit, found here. (https://vborg.vbsupport.ru/showthread.php?t=250418&highlight=postbit+custom+field)
I've managed to get this set up and my test forum is displaying the field. However, I would like to move this field and I'm running into problems figuring it out.
Right now, it displays the following (assuming user is "Admin" and custom field is "TEST"):
TEST
Admin
I would like to have it place the custom field in front of the user name, like so:
TEST Admin
Any help, or a gentle push in the right direction, is appreciated!
Thank you,
James
LifesGreatestGift
07-14-2011, 01:54 AM
show us your code for the elements and their placement in your postbit(or postbit_legacy) template. An example page would be even better.
Lynne
07-14-2011, 02:04 AM
We really need to see this in use to see the actual source code and also see your plugin/template code in order to make a recommendation on what to change.
J. Schultz
07-14-2011, 02:35 AM
Good news! I got it figured out. Guess I just needed to take a step away from the keyboard for a moment and look over what I had.
Here's the code taken from postbit_legacy:
<div class="postdetails">
<div class="userinfo">
<div class="username_container">
<vb:if condition="$post['field6']"> <dd>{vb:raw post.field6}</dd></vb:if>
<vb:if condition="$post['userid']">
{vb:raw memberaction_dropdown}
{vb:raw post.onlinestatus}
<vb:else />
Where 'field6' is my custom field. Turned out this:
https://vborg.vbsupport.ru/external/2011/07/75.jpg
I changed it as follows:
<div class="postdetails">
<div class="userinfo">
<div class="username_container">
<vb:if condition="$post['field6'] "$post['userid']">
{vb:raw post.field6}
{vb:raw memberaction_dropdown}
{vb:raw post.onlinestatus}
<vb:else />
And now I have what I was looking for:
https://vborg.vbsupport.ru/external/2011/07/76.jpg
Any critiques?
Now to get the text formatting to match :)
ForumExcellence
07-14-2011, 05:20 AM
Any critiques?
Now to get the text formatting to match :)
Change to:
<div class="postdetails">
<div class="userinfo">
<div class="username_container">
<vb:if condition="$post['field6']">
<span class="postbit-postfield6">{vb:raw post.field6}</span>
</vb:if>
<vb:if condition="$post['userid']">
{vb:raw memberaction_dropdown}
{vb:raw post.onlinestatus}
<vb:else />
Then, open postbit.css
Find:
.postbitlegacy .userinfo a.username, .eventbit .userinfo a.username {
clear:{vb:stylevar right};
font-size:{vb:stylevar font.fontSize}{vb:stylevar font.units};
font-weight:bold;
width: auto;
max-width:{vb:math {vb:stylevar postbitlegacy_userinfo_width} - {vb:math {vb:stylevar padding}*2} - 20px};
word-wrap:break-word;
}
There may be something different for your style after the emphasized line, so just look for that line and then copy everything between it and the }, then paste it right under (but leave the original!), then change where it says "a.username" on the one you pasted, to ".postbit-postfield6", and change ", .eventbit .userinfo a.username" to:
, .postbit .contact .postbit-postfield6
If you would like to use a specific colour for that text, find "font-weight:bold;", then add the following line underneath it (changing the emphasized text with the appropriate hex value, including the # sign - I've set it as white, most hex codes will be 6 characters long):
color:#fff;
You can also add this instead to use the default link colour:
color:{vb:stylevar link_color};
So the whole thing should now look something like:
.postbitlegacy .userinfo .postbit-postfield6, .postbit .contact .postbit-postfield6 {
clear:{vb:stylevar right};
font-size:{vb:stylevar font.fontSize}{vb:stylevar font.units};
font-weight:bold;
color:#fff;
width: auto;
max-width:{vb:math {vb:stylevar postbitlegacy_userinfo_width} - {vb:math {vb:stylevar padding}*2} - 20px};
word-wrap:break-word;
}
This will work even if you choose to change to the horizontal postbit template later.
If you are using specific HTML markups per usergroup, and would like your text to have the same markup for your postbit field based on each member's usergroup, the easiest way would be to use the following syntax (adding as many "<vb:elseif />" conditionals as you have usergroups with their own HTML markups which you'd like to duplicate, with the last "<vb:else />" being what shows for everybody else, and ending with a "</vb:if>"), making sure to add additional CSS rules (as above) for each new class, as required. For example:
<div class="postdetails">
<div class="userinfo">
<div class="username_container">
<vb:if condition="$post['field6']">
<vb:if condition="is_member_of($bbuserinfo, 6)">
<span class="postbit-postfield6-6">
<vb:elseif condition="is_member_of($bbuserinfo, 7)" />
<span class="postbit-postfield6-7">
<vb:else />
<span class="postbit-postfield6"></vb:if>{vb:raw post.field6}</span>
</vb:if>
<vb:if condition="$post['userid']">
{vb:raw memberaction_dropdown}
{vb:raw post.onlinestatus}
<vb:else />
In this case, I added an additional "-#" to the end of the class name to denote a particular usergroup number, however, you can change them however you like, as long as you maintain proper syntax (http://www.w3.org/TR/css3-syntax/). Remember to make the appropriate changes in both selector instances in each new rule (as emphasized):
.postbitlegacy .userinfo .postbit-postfield6-7, .postbit .contact .postbit-postfield6-7 {
clear:{vb:stylevar right};
font-size:{vb:stylevar font.fontSize}{vb:stylevar font.units};
font-weight:bold;
color:#000;
width: auto;
max-width:{vb:math {vb:stylevar postbitlegacy_userinfo_width} - {vb:math {vb:stylevar padding}*2} - 20px};
word-wrap:break-word;
}
J. Schultz
07-18-2011, 04:16 PM
Thank you, very much. Working exactly as I'd hoped, and looks sharp too :)
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.