The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
Using your User Profile Fields in your postbit templates (w/ all plugin method)
This article is written with the assumption that you have already created your own User Profile Fields in the User Profile Field Manager. If you need help with this, you may read about it in the manual here - http://www.vbulletin.com/docs/html/profile For the Purposes of this article, I will be referring to "fieldx" as the name of your profile field. Your real name will be found in the User Profile Manager in the "Name" column - field1, field2, etc. Adding the Profile Field to your postbit (or postbit_legacy) template For Single-Line Text Box, Multiple-Line Text Box, Single-Selection Radio Buttons, and Single-Selection Menu Method 1 - Modifying the Template Open the postbit or postbit_legacy template and find the area you want to add it to. For instance, to add it right after the user post count, find this:Method 2 - Using a template_hook I have always found it easier to just use the existing $template_hooks in the template and write a plugin to add these. In this case, there is a $template_hook right where we want it, after the user post count:For Multiple-Selection Menu and Multiple-Selection Checkbox It is a bit more complicated for these two types of selections since the options selected are stored as a binary number. If you just display the field using the method above, you will get a number, not a list of options selected. So, in order to use these types of fields, you will have to use the method below. Here is a thead that will explain the binary scheme - http://www.vbulletin.com/forum/showt...To-The-Postbit Method 1 - Modifying the Template Open the template and find the area you want to add it to. For instance, to add it right after the user post count, find this:Method 2 - Using a template_hook Find the template_hook you want to use. In this case, there is a $template_hook right where we want it, after the user post count:More Advanced If you like everything to be 'automatic' - meaning you don't have to supply any text at all, just use everything already stored in the database - then you can use a few of plugins to do the work for you. Plugin 1 - This plugin is used to get the phrasegroup "cprofilefield" added for use in the page so that you may use $vbphrase[fieldx_title] to get the Profile Field Title you entered in the User Profile Field Manager. ? hook location - init_startupPlugin 2 - This plugin is used to get the fields you defined for the profile in the User Profile Field Manager. ? hook location - showthread_postbit_createPlugin 3 - This plugin simply spits the data out into the postbit using the template_hook and using the phrase for the Title and the Options are all spit out with commas between them (if needed) into the postbit. ? hook location - postbit_display_complete |
#82
|
||||
|
||||
oh man im so shit at this lol
ok, so vB4.2.2 and editing in postbit template The field i've created is gender with 2 options male or female. Here is the code i've got in there. Its not working and i bet one of you guys will take 1 look and it will be so obvious lol |
#83
|
||||
|
||||
It's "field7", not "Field7".
|
#84
|
||||
|
||||
<vb:if condition="$post['field7']"><dt>Gender</dt> <dd>{vb:raw post.field7}</dd></vb:if>
Not working |
#85
|
|||
|
|||
Take off the conditionals so you just have this:
Code:
<dt>Gender</dt> <dd>{vb:raw post.field7}</dd> This is really a test that you are editing the correct template in the correct style, since now, even if your field id was wrong you should at least see "Gender" in the postbit. |
#86
|
||||
|
||||
Are you sure the poster has even set the gender in their profile?
|
#87
|
||||
|
||||
Yea, the poster is me hehe. good question tho
--------------- Added [DATE]1399059505[/DATE] at [TIME]1399059505[/TIME] --------------- AHHHH, i was editing 'postbit' not 'postbit_legacy' |
#88
|
|||
|
|||
The old ones are the best.
|
#89
|
|||
|
|||
Have been trying to use method 2 ...
This works >>>> if ($post[field40]) { $ImagePath = vB_Template_Runtime::fetchStyleVar('imgdir_misc'). '/critique/nocritique.png'; $template_hook['postbit_userinfo_right_after_posts'] .= '<br /><dt>Critique Level</dt><br /> <dd><img src="' . $ImagePath . '"/></dd>'; } Yielding both Critique Level: and an image. Adding conditional doesn't, if there is just one conditional I get Critique Level: and a broken image link; the only difference is the "& 4" - If I use with three conditionals I get 3 * Critique Level: s and 3 broken image links .... It also seems as though it is ignoring the "if" statement because it shows on every profile.>>>> if ($post[field40]) { if ($post[field40] & 4) $ImagePath = vB_Template_Runtime::fetchStyleVar('imgdir_misc'). '/critique/nocritique.png'; $template_hook['postbit_userinfo_right_after_posts'] .= '<br /><dt>Critique Level</dt><br /> <dd><img src="' . $ImagePath . '"/></dd>'; } I can hazard a guess that using three conditionals there could be a confusion over $ImagePath, but surely it should work with just the one condition ? I'm missing something rather simple I think ?! |
#90
|
||||
|
||||
You need some parenthesis after your second condition (why are you using a second one anyway?).
Code:
if ($post[field40]) { if ($post[field40] & 4) { $ImagePath = vB_Template_Runtime::fetchStyleVar('imgdir_misc').'/critique/nocritique.png'; $template_hook['postbit_userinfo_right_after_posts'] .= '<br /><dt>Critique Level</dt><br /> <dd><img src="' . $ImagePath . '"/></dd>'; } } |
#91
|
|||
|
|||
Not too sure what you mean by "why am I using a second condition...."
I'm following your method 2 : Quote:
[field40] contains 3 radio buttons. Looks like I need to keep hammering at it .... |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|