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 |
#92
|
||||
|
||||
Since you didn't use the code tags, it looked like your code was not all on one-line, which it needs to be if you don't use the parenthesis.
You don't use that code for a radio button though. That code is for Multiple-Selection Menu and Multiple-Selection Checkbox profile fields. You need to use the code for For Single-Line Text Box, Multiple-Line Text Box, Single-Selection Radio Buttons, and Single-Selection Menu profile fields. |
#93
|
||||
|
||||
Hi Lynne,
Is it possible to display a different image on the postbit depending on the option chosen on a single-selection menu? Example: "What is your favourite colour?" Red Blue Green Orange I've used method one but am suspecting that method two may actually be more suitable for this task. Thank you in advance, ProfC. |
#94
|
||||
|
||||
You could use either template edits or a plugin to do what you want. In the examples I show, just replace 'Your 1rst option' with '<img src="image.png" alt="Red Image" height="xx" width="yy">'
|
Благодарность от: | ||
ProfC |
#95
|
||||
|
||||
Thank you! I'll take a look and see what I get.
|
#96
|
||||
|
||||
Good advices thanks for share this
|
#97
|
||||
|
||||
I'm having a bit of trouble somewhere with this. I decided to go the plugin method for multiple selection fields, as it seemed to offer the means to set different things to display based on the option selected. Unfortunately, I haven't been able to get any further than it displaying "house memberships" (the field name) on the postbit.
I'm not sure whether I've even used the right method or not but the "single selection menu" method didn't appear to have the options to display a different result based on what was selected in the profile menu. Would it be possible for someone to tell me where I've gone wrong? (I get the sensation I'll be asking this a lot -sigh-) Thank you in advance Plugin code: Code:
if ($post['field17']) { $template_hook['postbit_userinfo_right_after_posts'] .= '<dt>House Membership</dt> <dd>'; if ($post['field17'] & 1) $template_hook['postbit_userinfo_right_after_posts'] .= '<img src="http://i.imgur.com/TdZqV1q.gif?1" title="Ravenclaw" alt="Ravenclaw" />'; if ($post['field17'] & 2) $template_hook['postbit_userinfo_right_after_posts'] .= 'Montresor'; if ($post['field17'] & 4) $template_hook['postbit_userinfo_right_after_posts'] .= 'Astor'; if ($post['field17'] & 8) $template_hook['postbit_userinfo_right_after_posts'] .= 'Lore'; if ($post['field17'] & 16) $template_hook['postbit_userinfo_right_after_posts'] .= 'Bluteisen-Ravenclaw'; if ($post['field17'] & 32) $template_hook['postbit_userinfo_right_after_posts'] .= 'Pendrake'; $template_hook['postbit_userinfo_right_after_posts'] .= '</dd>'; } |
#98
|
||||
|
||||
You want to use "==" instead of "&" in your conditionals. However, might I suggest using a switch statement instead?
PHP Code:
|
Благодарность от: | ||
ProfC |
#99
|
||||
|
||||
Thank you; although it appears I'm getting the same result using your version as I am with the one I added following the article.
|
#100
|
||||
|
||||
What hook location are you using?
|
#101
|
||||
|
||||
"postbit_display_complete" as mentioned in the article.
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|