Register Members List Search Today's Posts Mark Forums Read

Reply
 
Article Options
[How-to] Add more tabs to the vB 3.7 profile pages
calorie
Join Date: May 2003
Posts: 2,804

by calorie calorie is offline 19 Dec 2007
Rating: (1 vote - 5.00 average)

If you want to add more tabs to the vB 3.7 profile pages, assuming JavaScript is enabled, or more blocks if JavaScript is off, then this tutorial is for you. If you like to learn in a trial by fire sort of way, create a new template titled memberinfo_block_mymodification with the following content:

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

Add a new plugin to the member_build_blocks_start hook with the following PHP code:

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

Now visit your profile page to test it out. You should see a 'My Modification' tab that when clicked shows you the following text: Content to show in the tab. Exciting huh? Of course you need to add your own custom code for what to display, but this tutorial isn't about that, but rather to show you how to add tabs to the profile pages.

If you want to learn a bit more of the details, first consider this part:

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

The $blocklist variable contains the default blocks. You merge to that another array where the key 'mymodification' references an array which sets a class to use, the title of the tab on the profile page, and the hook location. You can set whatever you want for title including the use of $vbphrase but in the example 'My Modification' is used. As for the hook location, you can use profile_left_first or profile_left_last depending on whether you want your new tab to be left or right of the current tabs, respectively.

Next consider the next part:

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

The class needs to be called vB_ProfileBlock_MyModification extends vB_ProfileBlock and note that part of the class name is vB_ProfileBlock_MyModification where MyModification comes from the class value set in your addition to the $blocklist variable. Inside the class, $template_name is set to the template to use, the confirm_empty_wrap function returns false to not create an empty block, the confirm_display function tests whether there is any content to display, and the prepare_output function is where you’d want to add your own custom code to fetch whatever you want to display, setting $this->block_data['mymodification'] to the content you want displayed. Remember variable scope when you add your own code, as you are inside a function that is inside a class.

Now there is the new template itself:

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

Note that $block_data[mymodification] contains whatever $this->block_data['mymodification'] contains in the prepare_output function inside the class, and because a hook location is set in your addition to the $blocklist variable, there are no manual template edits to make. Hooray! You should of course replace 'mymodification', 'MyModification', and 'My Modification' throughout this tutorial with something meaningful for your modification.

Finally there are other things that can be added to modifications such as options, and these can be seen in the vB class_profileblock.php and member.php files, though this tutorial should get you on your way to adding more content to the profile pages via additional tabs, but remember not to go overboard with queries, because even though you need to click the tab to see the content, whatever queries you run get run on page load, not tab click. Enjoy!

Fine print: tutorial based on vB 3.7.0 Beta 2, no redistribution without permission.
Views: 49951
Reply With Quote
Comments
  #2  
Old 19 Dec 2007, 10:17
Magnumutz's Avatar
Magnumutz Magnumutz is offline
 
Join Date: Feb 2006
Real name: Alex
VERY nice calorie... this is really helpful.
__________________

Reply With Quote
  #3  
Old 19 Dec 2007, 11:21
Triky's Avatar
Triky Triky is offline
 
Join Date: Mar 2007
Location: [Italy]
This will be helpfull.
Thank you!
__________________
I'm italian, I am learning english.. so, please, if you see any errors in my grammar or spelling, let me know via PM. Danke!
Reply With Quote
  #4  
Old 24 Dec 2007, 03:44
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Real name: Lynne
Thank you so much for this! It was very helpful.
Reply With Quote
  #5  
Old 26 Dec 2007, 17:43
hfr-Neil's Avatar
hfr-Neil hfr-Neil is offline
 
Join Date: Dec 2006
Thank you for this tuto
__________________

www.gtr-racinghfr.net
Reply With Quote
  #6  
Old 01 Jan 2008, 18:07
eurofunny eurofunny is offline
 
Join Date: Aug 2006
Hi, nice Tutorial. Thx
__________________
My-CheckPoint.de Hier checkst Du was abgeht

Last edited by eurofunny; 01 Jan 2008 at 19:05.
Reply With Quote
  #7  
Old 02 Jan 2008, 04:31
Audentio's Avatar
Audentio Audentio is offline
 
Join Date: Mar 2007
Real name: Mike
Excellent, very nice. Thanks for making this for us.
Reply With Quote
  #8  
Old 03 Jan 2008, 00:44
Zaiaku's Avatar
Zaiaku Zaiaku is offline
 
Join Date: Jul 2007
Useful and Helpful Thx!
__________________
Live everyday as if it was your last, because one day it just may be.
Reply With Quote
  #9  
Old 03 Jan 2008, 00:52
Berker Unluer Berker Unluer is offline
 
Join Date: Dec 2007
Thnx! Excelent!
Reply With Quote
  #10  
Old 20 Jan 2008, 06:33
bdude's Avatar
bdude bdude is offline
 
Join Date: Dec 2005
Real name: Bryce
How do I create a block on the right hand side?
__________________
Come join my Blogging Forum. Or try my blog for forum owners.
Reply With Quote
  #11  
Old 20 Jan 2008, 21:53
ragtek's Avatar
ragtek ragtek is offline
 
Join Date: Mar 2006
Location: austria, croatia
with:

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

possible locations:

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

__________________
my addons: http://ragtek.github.com
Reply With Quote
  #12  
Old 26 Jan 2008, 19:51
eNforce's Avatar
eNforce eNforce is offline
 
Join Date: Aug 2004
For the contents of the tab how can I pull a custom profile field?


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

It just outputs as "$userinfo[field8]" instead of what was typed in via User CP.
Reply With Quote
  #13  
Old 11 Feb 2008, 21:57
marcossalazar marcossalazar is offline
 
Join Date: Feb 2007
Thanks for the article!

Last edited by marcossalazar; 28 Feb 2008 at 13:54.
Reply With Quote
  #14  
Old 23 Feb 2008, 16:16
Wayne Luke's Avatar
Wayne Luke Wayne Luke is offline
 
Join Date: Jan 2002
Real name: Wayne
Originally Posted by eNforce View Post
For the contents of the tab how can I pull a custom profile field?
Do something like this for your prepare_output function

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

__________________
Wayne Luke
Get started with your own social network. Purchase and download vBulletin today.
Reply With Quote
  #15  
Old 25 Feb 2008, 15:09
Neutral Singh's Avatar
Neutral Singh Neutral Singh is offline
 
Join Date: Sep 2004
Real name: Aman Singh
How can we create similar tab like "About Me" contents of which are user editable on the page itself. This facility should have inbuilt into vbulletin as a default.
Reply With Quote
Reply

Similar Article
Article Author Type Replies Last Post
Forum Home Enhancements Flipped tabs = Swivel tabs = INVERTED TABS Deepdog009 vBulletin 3.7 Add-ons 29 20 Jan 2010 09:39



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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


New To Site? Need Help?

All times are GMT. The time now is 01:19.

Layout Options | Width: Wide Color: