PDA

View Full Version : Custom Field in Postbit_legacy


J. Schultz
14 Jul 2011, 02:39
Hi all,

I read through Lynne's great article on adding custom fields to the postbit, found here. (http://www.vbulletin.org/forum/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
14 Jul 2011, 02:54
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
14 Jul 2011, 03:04
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
14 Jul 2011, 03:35
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:

http://i.imgur.com/OdDay.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:

http://i.imgur.com/KNywV.jpg


Any critiques?

Now to get the text formatting to match :)

ForumExcellence
14 Jul 2011, 06:20
Any critiques?

Now to get the text formatting to match :)

Change to:



Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------




Then, open postbit.css

Find:



Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------




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:



Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------




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



Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------




You can also add this instead to use the default link colour:



Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------




So the whole thing should now look something like:



Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------




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:



Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------




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



Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------

J. Schultz
18 Jul 2011, 17:16
Thank you, very much. Working exactly as I'd hoped, and looks sharp too :)