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
  #2  
Old 06-29-2011, 01:38 PM
Princeton's Avatar
Princeton Princeton is offline
 
Join Date: Nov 2001
Location: Vineland, NJ
Posts: 6,693
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

thank you cellarius - great article! :up:
Reply With Quote
Благодарность от:
cellarius
  #3  
Old 06-29-2011, 01:42 PM
cellarius's Avatar
cellarius cellarius is offline
 
Join Date: Aug 2005
Posts: 1,987
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks
Reply With Quote
Благодарность от:
Princeton
  #4  
Old 06-29-2011, 07:46 PM
BirdOPrey5's Avatar
BirdOPrey5 BirdOPrey5 is offline
Senior Member
 
Join Date: Jun 2008
Location: New York
Posts: 10,610
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Will come in handy!
Reply With Quote
  #5  
Old 06-29-2011, 08:41 PM
Pandemikk Pandemikk is offline
 
Join Date: Jul 2009
Posts: 292
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Great job. I wish this article was here when I first wanted to add a new profile tab! Would have saved me hours of headache over such a small little problem.
Reply With Quote
  #6  
Old 07-03-2011, 02:21 PM
BCP Hung BCP Hung is offline
 
Join Date: May 2011
Location: Vietnam
Posts: 155
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It really important with me !
Great work !

(I can't like your post, why ??? )
Reply With Quote
  #7  
Old 07-04-2011, 08:56 AM
tkhalbiz tkhalbiz is offline
 
Join Date: Aug 2009
Posts: 6
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I followed all the steps, but it does not work
can some one help me ?
Reply With Quote
  #8  
Old 07-04-2011, 10:40 AM
cellarius's Avatar
cellarius cellarius is offline
 
Join Date: Aug 2005
Posts: 1,987
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

No, sorry, you're just giving too much information...

What vB version exactly are you using?
What exactly does not work?
What code did you use where?

Honestly, what help exactly do you expect on the simple statement "it does not work"? Only thing I possibly could offer on that grounds would be: fix the error, then it will.

--------------- Added [DATE]1309779783[/DATE] at [TIME]1309779783[/TIME] ---------------

Quote:
Originally Posted by Getamped 1404 View Post
(I can't like your post, why ??? )
They improved the likes system, maybe that was the problem. Feel free to try again
Reply With Quote
Благодарность от:
BCP Hung
  #9  
Old 07-06-2011, 06:37 AM
tkhalbiz tkhalbiz is offline
 
Join Date: Aug 2009
Posts: 6
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hello,
Im sorry for no precision
My vbulletin version : 4.1.4
i have create a plugin at hook member_complete
with this code :
Code:
if (isset($vbulletin->GPC['tab']))
{
    $selected_tab = $vbulletin->GPC['tab'];
}
$blockinfo['title'] = "Test Title";
$blockid = "test";
$taburl = $memberurl = fetch_seo_url('member', $prepared) . "&amp;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('custom_profile_tab_test');
$templater->register('selected_tab', $selected_tab);
$templater->register('test_tab_content', $test_tab_content);
$template_hook['profile_tabs'] .= $templater->render();
i just copy past original code
then i have create template custom_profile_tab_test with this code :
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>
and after i go to profile page to check new tabs but nothing to see
Reply With Quote
  #10  
Old 07-06-2011, 07:18 AM
cellarius's Avatar
cellarius cellarius is offline
 
Join Date: Aug 2005
Posts: 1,987
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Then you either have not activated the plugin you created, have deactivated plugins globally, created the template for the wrong style, or use a customized style where the needed template hook is not present.

Since that's, as far as I can see, the unchanged code from the firstpost, I can guarantee this works.
Reply With Quote
Благодарность от:
scoles15
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:14 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.04932 seconds
  • Memory Usage 2,337KB
  • Queries Executed 24 (?)
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
  • (4)bbcode_code
  • (1)bbcode_quote
  • (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
  • (2)pagenav_pagelink
  • (10)post_thanks_box
  • (21)post_thanks_box_bit
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (5)post_thanks_postbit
  • (10)post_thanks_postbit_info
  • (9)postbit
  • (10)postbit_onlinestatus
  • (10)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