Register Members List Search Today's Posts Mark Forums Read

Reply
 
Article Options
Using your User Profile Fields in your postbit templates (w/ all plugin method)
Lynne
Join Date: Sep 2004
Posts: 40,355

California
by Lynne Lynne is offline 13 Sep 2010

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:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

And then, add this underneath:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Change "fieldx" to your actual field name and the green field to whatever you want. Notice the html I used is similar to the html used for the text above me new field.
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:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

So, we would create a plugin with these specifications:
hook location - postbit_display_complete
Title - Add User Profile Fields to Postbit Templates
Plugin is Active - Yes
Plugin PHP Code -

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Change "fieldx" to your actual field name and the green field to whatever you want. Again, notice the html I used is similar to the html used for the text above me new field. Whichever template_hook you use, you should look at the template to see what sort of html is being used around the hook so that you may use similar, proper html also.
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:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

And then add this underneath (this is assuming the field has 5 options):

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Change "fieldx" to your actual field name and the green field to whatever you want. Notice the html I used is similar to the html used for the text above me new field.
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:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

So, we would create a plugin with these specifications:
hook location - postbit_display_complete
Title - Add User Profile Fields to Postbit Templates
Plugin is Active - Yes
Plugin PHP Code -

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Change "fieldx" to your actual field name and the green field to whatever you want. Again, notice the html I used is similar to the html used for the text above me new field. Whichever template_hook you use, you should look at the template to see what sort of html is being used around the hook so that you may use similar, proper html also.
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_startup
Title - Add User Profile Fields to Postbit Templates - 1
Plugin is Active - Yes
Plugin PHP Code -

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Plugin 2 - This plugin is used to get the fields you defined for the profile in the User Profile Field Manager.
hook location - showthread_postbit_create
Title - Add User Profile Fields to Postbit Templates - 2
Plugin is Active - Yes
Plugin PHP Code -

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Plugin 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
Title - Add User Profile Fields to Postbit Templates - 3
Plugin is Active - Yes
Plugin PHP Code -

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Change "fieldx" to your actual field name and the orange, purple, and brown fields should 'match-up' and have the same names.

Last edited by Lynne : 13 Sep 2010 at 17:03.
Views: 17232
Reply With Quote
Comments
  #2  
Old 14 Sep 2010, 16:09
Dave-M Dave-M is offline
 
Join Date: Sep 2007
Hi Lynne, thanks for this, brilliant

I wonder if it would be possible for you to implement a dropdown for this, so that it's like wired1's mod? His has broken CSS at the moment and there's no sign of him being able to fix it soon, it would be fantastic if you could make something similar.

http://www.vbulletin.org/forum/showthread.php?t=248651
Reply With Quote
  #3  
Old 14 Sep 2010, 16:15
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Real name: Lynne
This is an article, not a modification. You may do whatever you want with the information found in here.
__________________
Try a search before posting for help. Many users won't, and don't, help if the question has been answered several times before.
W3Schools -
Online vBulletin Manual
If I post some CSS and don't say where it goes, put it in the additional.css template.
I will NOT help via PM (you will be directed to post in the forums for help.)
Reply With Quote
  #4  
Old 20 Sep 2010, 15:39
lightbox lightbox is offline
 
Join Date: Jun 2004
Thanks a lot for this article.

Is there a way to use specific User Profile Fields in vbcms article pages (Template vbcms_content_article_page)?

Cheers,
Martin
Reply With Quote
  #5  
Old 20 Sep 2010, 16:00
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Real name: Lynne
Originally Posted by lightbox View Post
Thanks a lot for this article.

Is there a way to use specific User Profile Fields in vbcms article pages (Template vbcms_content_article_page)?

Cheers,
Martin
I'm sure there is, but I didn't cover that in this article. This article is just for the postbit(_legacy) template.
__________________
Try a search before posting for help. Many users won't, and don't, help if the question has been answered several times before.
W3Schools -
Online vBulletin Manual
If I post some CSS and don't say where it goes, put it in the additional.css template.
I will NOT help via PM (you will be directed to post in the forums for help.)
Reply With Quote
  #6  
Old 22 Sep 2010, 23:30
svoophod svoophod is offline
 
Join Date: Sep 2010
thanks so much, this is great!
Reply With Quote
  #7  
Old 26 Sep 2010, 19:13
COL NIL SATIS COL NIL SATIS is offline
 
Join Date: Aug 2009
Real name: Col
Thanks lynne..this is great!!!! top advice ..
Reply With Quote
  #8  
Old 16 Oct 2010, 00:43
djr's Avatar
djr djr is offline
 
Join Date: Nov 2001
Real name: Jean-Paul
Hi Lynne,

Is it easy to backport this to vB 3.8.6? Besides the obvious variable name changes, would the plugin solution work for vB 3.8.6 as well? (meaning: does vB 3.8.6 have the same hooks present?). Or does it need to be completely rewritten?

I'd love to have this a plugin solution for our vB 3.8.6 board, since it's getting tiresome to redo all the template changes after every upgrade (plus I like the plugin solution better)

Thanks for an excellent article! Much appreciated.
__________________
- highly ill, but always intelligent -


- User Age in CP (together with the_sisko)
Reply With Quote
  #9  
Old 16 Oct 2010, 01:00
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Real name: Lynne
The method of calling the phrasegroup may have been different in 3.8, so you would have to change that. Other than that, you'd just have to change the html you are outputting as <li> wasn't used in 3.8 either. However, I've never tried it on my 3.8 board, so I can't say for sure.
__________________
Try a search before posting for help. Many users won't, and don't, help if the question has been answered several times before.
W3Schools -
Online vBulletin Manual
If I post some CSS and don't say where it goes, put it in the additional.css template.
I will NOT help via PM (you will be directed to post in the forums for help.)
Reply With Quote
  #10  
Old 04 Nov 2010, 13:10
voglermc's Avatar
voglermc voglermc is offline
 
Join Date: Oct 2006
Real name: Mark V
<a href="album.php?{vb:raw session.sessionurl}u={vb:raw post.userid}" title="View {vb:raw post.username}'s Album" rel="nofollow">View {vb:raw post.username}'s Album</a>

Last edited by voglermc : 04 Nov 2010 at 17:06.
Reply With Quote
  #11  
Old 04 Nov 2010, 15:40
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Real name: Lynne
You don't need user profile fields to link to album pages (unless you are doing something different?). I'm sure there is a mod or a thread about what you want to do if you are talking about just a plain link that has nothing to do with profile fields.
__________________
Try a search before posting for help. Many users won't, and don't, help if the question has been answered several times before.
W3Schools -
Online vBulletin Manual
If I post some CSS and don't say where it goes, put it in the additional.css template.
I will NOT help via PM (you will be directed to post in the forums for help.)
Reply With Quote
  #12  
Old 04 Nov 2010, 16:02
voglermc's Avatar
voglermc voglermc is offline
 
Join Date: Oct 2006
Real name: Mark V

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


Last edited by voglermc : 04 Nov 2010 at 17:05.
Reply With Quote
  #13  
Old 04 Nov 2010, 16:29
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Real name: Lynne
Then you should post in the main forums about it, not in some random article about the profile fields.
__________________
Try a search before posting for help. Many users won't, and don't, help if the question has been answered several times before.
W3Schools -
Online vBulletin Manual
If I post some CSS and don't say where it goes, put it in the additional.css template.
I will NOT help via PM (you will be directed to post in the forums for help.)
Reply With Quote
  #14  
Old 30 Nov 2010, 21:32
Black Tiger's Avatar
Black Tiger Black Tiger is offline
 
Join Date: Apr 2004
Looks very interesting. You told me this was possible to make compatible for v3.8.x by changing some html code.

Could you or somebody else tell me what exactly to change? I can read a bit of php, but don't know what to do with it, so I would really need a "look for this and replace with that" solution. It has no hurry though.

Thanks in advance!
__________________
Greetings, Black Tiger
Reply With Quote
  #15  
Old 30 Nov 2010, 23:03
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Real name: Lynne
Did you see this for 3.8? How To Add Custom Profile Field Information To The Postbit

The only thing I think she doesn't cover is doing it all via pluginand it isn't much different at all for 3.8.

Plugin 1
hook location - init_startup
Title - Add User Profile Fields to Postbit Templates - 1
Plugin is Active - Yes
Plugin PHP Code -

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Plugin 2
hook location - showthread_postbit_create
Title - Add User Profile Fields to Postbit Templates - 2
Plugin is Active - Yes
Plugin PHP Code -


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Plugin 3
hook location - postbit_display_complete
Title - Add User Profile Fields to Postbit Templates - 3
Plugin is Active - Yes
Plugin PHP Code -

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

__________________
Try a search before posting for help. Many users won't, and don't, help if the question has been answered several times before.
W3Schools -
Online vBulletin Manual
If I post some CSS and don't say where it goes, put it in the additional.css template.
I will NOT help via PM (you will be directed to post in the forums for help.)
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Article Options

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Jump


New To Site? Need Help?

All times are GMT. The time now is 02:56.

Layout Options | Width: Wide Color: