vBulletin Mods

The Official vBulletin Modifications Site
https://www.vbulletin.org/forum/showthread.php?t=165554

[How-to] Add more tabs to the vB 3.7 profile pages
by calorie
19 Dec 2007 08:29

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.

Magnumutz 19 Dec 2007 11:17

VERY nice calorie... this is really helpful.

Triky 19 Dec 2007 12:21

This will be helpfull. :)
Thank you!

Lynne 24 Dec 2007 04:44

Thank you so much for this! It was very helpful.

hfr-Neil 26 Dec 2007 18:43

Thank you for this tuto ;)

eurofunny 01 Jan 2008 19:07

Hi, nice Tutorial. Thx

Audentio 02 Jan 2008 05:31

Excellent, very nice. Thanks for making this for us.

Zaiaku 03 Jan 2008 01:44

Useful and Helpful Thx!

Berker Unluer 03 Jan 2008 01:52

Thnx! Excelent!

bdude 20 Jan 2008 07:33

How do I create a block on the right hand side?

ragtek 20 Jan 2008 22:53

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.


eNforce 26 Jan 2008 20:51

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.

marcossalazar 11 Feb 2008 22:57

Thanks for the article!

Wayne Luke 23 Feb 2008 17:16

Quote:

Originally Posted by eNforce (Post 1429515)
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.


Neutral Singh 25 Feb 2008 16:09

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.


All times are GMT. The time now is 21:10.

Powered by vBulletin® Version 3.8.13
Copyright © 2019, MH Sub I, LLC dba vBulletin. All Rights Reserved. vBulletin® is a registered trademark of MH Sub I, LLC
Copyright ©2001 - , vbulletin.org. All rights reserved.