Go Back   vb.org Archive > vBulletin Article Depository > Read An Article > vBulletin 4 Articles
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
[HOW TO - vB4] Adding a New Tab in Member Profile - Reloaded
cellarius's Avatar
cellarius
Join Date: Aug 2005
Posts: 1,987

 

Show Printable Version Email this Page Subscription
cellarius cellarius is offline 06-28-2011, 10:00 PM

This tutorial is an update of Dylanblitz' howto for older versions. Credits to him, and thanks for giving me green light for building on his ideas.

This has been tested with [S]4.1.4[/S] 4.2,[S] but should work as far back as 4.0.8, when profile customization was reintroduced. [/S]
[Explanation: At least with version 4.1.8, the template name convention for profile tabs was changed. If you want to code for an earlier version, use custom_profile_tab_test as template name.]



The result will look like this:

Attachment 130539

First step

To create a new member profile tab, create a plugin at hook member_complete
Code:
if (isset($vbulletin->GPC['tab']))
{
    $selected_tab = $vbulletin->GPC['tab'];
}
$blockinfo['title'] = "Test Title";
$blockid = "test";
$taburl = $memberurl = fetch_seo_url('member', $prepared) . "&tab=test#test";

$templater = vB_Template::create('memberinfo_tab');
$templater->register('selected_tab', $selected_tab);
$templater->register('relpath', $relpath);
$templater->register('blockinfo', $blockinfo);
$templater->register('blockid', $blockid);
$templater->register('taburl', $taburl);
$template_hook['profile_tabs_last'] .= $templater->render();  

// ### Your code to fill the tab ###
// Don't forget you need to register any variables for use in templates 

$test_tab_content = "Congratulations, you can see me, I'm your PHP Code!";

$templater = vB_Template::create('memberinfo_block_test');
$templater->register('selected_tab', $selected_tab);
$templater->register('test_tab_content', $test_tab_content);
$template_hook['profile_tabs'] .= $templater->render();
This code creates the tab and inserts it as the last tab in the row. You
  • should give the tab its own unique id. In this case, we use test. If you change it, make sure you do so everywhere in the plugin and in the template. It has to be identical everywhere
  • can add custom code to fill your tab, if the content is not static html. In that case you would only add code to the template.
  • have to register any variables you want to output in the template, if you add custom code. You will be able to call that variable by using {vb:var test_tab_content} in the template.
  • choose a name for the template you will be calling to show your tab's content.
    Note that template names are case sensitive: test is not the same as TEST or Test. Remember that in step 2!



Second step


The second step to a custom profile tab is to create a new template. It has to be the name you used in your php code to create it, in our case: memberinfo_block_test.
Code:
<div id="view-test" class="<vb:if condition="$selected_tab == 'test'">selected_view_section<vb:else />view_section</vb:if><vb:if condition="$userinfo['userid'] != $bbuserinfo['userid']"> vm_other_prof</vb:if>">
    <div class="blocksubhead subsectionhead userprof_headers userprof_headers_border">     
        <h4 class="subsectionhead-understate">Test</h4>
    </div>
    <br />This is a <b>custom tab</b> test.<br /> 
    {vb:raw test_tab_content}
</div>
This is the template for your tab content. You
  • have to adapt the id in several cases. Note that they have to be absolutely identical again.
  • can add static text and html code into the template.
  • can print the output of the variable that you saved the result of your php code in and that you registered correctly.



Direct access


If you want to access your custom profile tag directly, append &tab=test#testto the profile URL.

That's it
Reply With Quote
  #12  
Old 07-06-2011, 07:25 AM
tkhalbiz tkhalbiz is offline
 
Join Date: Aug 2009
Posts: 6
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ok i will check all this point and come back
Reply With Quote
  #13  
Old 07-26-2011, 10:45 AM
WorldCraft WorldCraft is offline
 
Join Date: Jun 2010
Posts: 240
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Awesome thanks!
Reply With Quote
  #14  
Old 07-28-2011, 01:20 PM
John Tran John Tran is offline
 
Join Date: Jun 2011
Posts: 5
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Installed, but I have a quick question. I know I am asking this in the wrong area but I can't seem to find help anywhere. I installed this tab plugin, now I would like it to display member albums in the tab, is there anyway you can help with this?
Reply With Quote
  #15  
Old 08-25-2011, 01:45 PM
n.stanley n.stanley is offline
 
Join Date: May 2011
Posts: 20
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Sorry to sound silly, but where can I find these hooks/plugins?
Is it editing a file directly, or something found within the Administration section?

Sorry..

Edit: Found it out, god bless, google.
Reply With Quote
  #16  
Old 08-29-2011, 09:43 AM
n.stanley n.stanley is offline
 
Join Date: May 2011
Posts: 20
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Question;
After creating this tab, how can you specify the USER ID of the members profile you're on?
Reply With Quote
  #17  
Old 09-01-2011, 06:31 AM
cellarius's Avatar
cellarius cellarius is offline
 
Join Date: Aug 2005
Posts: 1,987
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Try
PHP Code:
$prepared['userid'
in the plugin,

to use it in the template you would probably have to register it first.
Reply With Quote
  #18  
Old 10-13-2011, 07:20 PM
berritt berritt is offline
 
Join Date: Oct 2011
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

this might be a stupid question, but is this an area that is editable by the user? Like if said user wanted to add more to their profile such as their favorite things, etc.
Reply With Quote
  #19  
Old 10-14-2011, 03:18 AM
BirdOPrey5's Avatar
BirdOPrey5 BirdOPrey5 is offline
Senior Member
 
Join Date: Jun 2008
Location: New York
Posts: 10,610
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

no.

You would have to supply fields to everyone via the Admin CP -> User Profile Field Manager. You can make them optional so only users who want to fill them out have to- but they would all show under "About Me."
Reply With Quote
  #20  
Old 03-21-2012, 04:53 PM
Altari Altari is offline
 
Join Date: Sep 2011
Posts: 38
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hello,

Sorry for my bad english, i'm french

How to add this profile tab with php code in a file .php and not in a plugin ?

Thank you
Reply With Quote
  #21  
Old 03-21-2012, 05:43 PM
cellarius's Avatar
cellarius cellarius is offline
 
Join Date: Aug 2005
Posts: 1,987
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Sorry, I don't know what you want to do. If you want to add any tabs to any php page, this is not for you.
Reply With Quote
Reply


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

Forum Jump


All times are GMT. The time now is 04:10 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.06803 seconds
  • Memory Usage 2,331KB
  • Queries Executed 26 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (2)bbcode_code
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_article
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)pagenav_pagelink
  • (11)post_thanks_box
  • (17)post_thanks_box_bit
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete