Go Back   vb.org Archive > vBulletin Article Depository > Read An Article > vBulletin 4 Articles

Reply
 
Thread Tools
[HOW TO - vB4] Adding a New Tab in Member Profile
Dylanblitz
Join Date: Oct 2005
Posts: 732

 

OC, California
Show Printable Version Email this Page Subscription
Dylanblitz Dylanblitz is offline 02-13-2010, 10:00 PM

If you are using anything above vB4.0.8 then refer to cellarius' updated article.
https://vborg.vbsupport.ru/showthread.php?p=2214470


I haven't seen a tutorial on doing this and I had to do it for a mod of mine, so I figured I would share. It is actually quite a bit easier to do in vb4 then it was before.

You will need 4 templates and 2 plugins. You could reduce it down to 2 templates but mine is used for distribution so I have to account for all versions.

First Template: This will create the tab next to About Me, Friends, etc

(my_data_tab)
Quote:
<dd<vb:if condition="$selected_tab == 'test'"> class="selected"</vb:if>><a id="test-tab" href="{vb:raw relpath}#test" onclick="return tabViewPicker(this);">Test</a></dd>
Where the text is red you can either leave it or replace it with your own reference. Just make sure it is the same throughout.

Second Template: The data you want to show.

(my_data_data)
Quote:
<div id="view-test" class="<vb:if condition="$selected_tab == 'test'">selected_view_section<vb:else />view_section</vb:if>">
<div class="blockbody">
<div class="blockrow">
<ul class="friends_list floatcontainer">
{vb:raw new_user_data}
</ul>
</div>
</div>
</div>
Same thing here, change the text in red to match the previous template.

Third Template: This will create the tab next to About Me, Friends, etc (4.0.8+)

(my_data_tab_408)
Quote:
<style>
#test'-tab, #test'-tab a:hover {height:25px; display:inline; background-color:transparent; margin:0px; padding:0px; text-align:center; border:none;}
a:hover#test'-tab {background:transparent;}
</style>

<dd<vb:if condition="$selected_tab == 'test''"> class="userprof_module" <vb:else /> class="userprof_moduleinactive"</vb:if>><a id="test'-tab" href="{vb:raw relpath}?tab=test'#test'-content" onclick="return tabViewPicker(this);">Test</a></dd>
Where the text is red you can either leave it or replace it with your own reference. Just make sure it is the same throughout.

Fourth Template: The data you want to show (4.0.8+).

(my_data_data_408)
Quote:
<div id="view-test'-content" class="<vb:if condition="$selected_tab == 'test''">selected_view_section<vb:else />view_section</vb:if>">
<div class="blockbody">
<div class="blockrow">
<ul class="friends_list floatcontainer">
{vb:raw new_user_data}
</ul>
</div>
</div>
</div>
Same thing here, change the text in red to match the previous template.



Now the first plugin
Hook Location: member_build_blocks_start
Title: Whatever you want to call it
Plugin Code
PHP Code:

if ($vbulletin->versionnumber "4.0.8")
{
$templater vB_Template::create('my_data_tab');
} else {
$templater vB_Template::create('my_data_tab_408');
}

$templater->register('selected_tab'$selected_tab);
$templater->register('relpath'$relpath);

if (
$vbulletin->versionnumber "4.0.2")
{
$template_hook['profile_left_last'] .= $templater->render();
} else {
$template_hook['profile_tabs_last'] .= $templater->render();
}


//Do your processing to get your data ready here.
$new_user_data "Data for the new tab";


if (
$vbulletin->versionnumber "4.0.8")
{
$templater vB_Template::create('my_data_data');
} else {
$templater vB_Template::create('my_data_data_408');
}

$templater->register('selected_tab'$selected_tab);
$templater->register('new_user_data'$new_user_data);

    if (
$vbulletin->versionnumber "4.0.2")
    {
$template_hook['profile_left'] .= $templater->render();
    } else {
$template_hook['profile_tabs'] .= $templater->render();
    } 
Second plugin
Hook Location: cache_templates
Title: Whatever you want to call it
PHP Code:
if (THIS_SCRIPT == 'member')
{
    if (
$vbulletin->versionnumber "4.0.8")
    {
    
$cache[] = 'my_data_tab';
    
$cache[] = 'my_data_data';
    } else {
    
$cache[] = 'my_data_tab_408';
    
$cache[] = 'my_data_data_408';
    }

And the result
Attached Images
File Type: png new_tab.png (6.0 KB, 0 views)
Reply With Quote
  #32  
Old 01-10-2011, 12:33 AM
BirdOPrey5's Avatar
BirdOPrey5 BirdOPrey5 is offline
Senior Member
 
Join Date: Jun 2008
Location: New York
Posts: 10,610
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The two 408 templates have an error in the code, there's an extra single quote (') after the word "test" in the conditionals. You'll get an error if you try to save the templates without fixing it. Once fixed it worked great on my 4.0.8.

Edit- Actually there's quite a few extra single quotes in 408 data tab as well breaking the style, it seems there's an extra single quote after each red test in the code. Once they are all removed it works well.
Reply With Quote
  #33  
Old 04-09-2011, 09:18 PM
computer22 computer22 is offline
 
Join Date: Dec 2008
Posts: 19
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I have a problem with my profile tab, when loading it it's displaying it like in the picture about the red line. When I click the "button" then it turns right into the correct color and format (below red line)



Does anyone know what could cause that?
Reply With Quote
  #34  
Old 05-23-2011, 02:04 PM
cellarius's Avatar
cellarius cellarius is offline
 
Join Date: Aug 2005
Posts: 1,987
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yep, the profile tabs template has changed a little in previous versions.

I would advise not to create a specific template for your tab - template nr. 1 (my_data_tab) in the tutorial is actually unnecessary. I call the standard memberinfo_tab instead and prefill the necessary variables. Saves you one template. PHP for this looks like that:

PHP 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(); 
Also, the hook where the plugin needs to reside is member_complete, not member_build_blocks_start. Else the direct link to the tab by URL (member.php?123-testuser&tab=test#test) will not work properly.
Reply With Quote
  #35  
Old 06-14-2011, 02:34 AM
Pandemikk Pandemikk is offline
 
Join Date: Jul 2009
Posts: 292
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I can't get this to work. I used the above's PHP code for the plugin and the my_data_data_408 for the template.

The tab shows up fine but when I click it nothing is shown in the box.
Reply With Quote
  #36  
Old 06-14-2011, 05:15 AM
cellarius's Avatar
cellarius cellarius is offline
 
Join Date: Aug 2005
Posts: 1,987
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Have you seen my post directly over yours?
Reply With Quote
  #37  
Old 06-14-2011, 06:20 AM
Pandemikk Pandemikk is offline
 
Join Date: Jul 2009
Posts: 292
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yes, I used your PHP code for the plugin and the my_data_data_408 for the template.
Reply With Quote
  #38  
Old 06-15-2011, 03:32 PM
Pandemikk Pandemikk is offline
 
Join Date: Jul 2009
Posts: 292
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Really need some help with this. It's driving me nuts that vB still hasn't a decent article on these member profile tabs.
Reply With Quote
  #39  
Old 06-20-2011, 04:24 AM
Pandemikk Pandemikk is offline
 
Join Date: Jul 2009
Posts: 292
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

++++ you +++++++ then.
Reply With Quote
  #40  
Old 06-20-2011, 06:54 AM
cellarius's Avatar
cellarius cellarius is offline
 
Join Date: Aug 2005
Posts: 1,987
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm sure that this childish behaviour is going to get you LOTS of help.
Reply With Quote
  #41  
Old 06-20-2011, 05:43 PM
Pandemikk Pandemikk is offline
 
Join Date: Jul 2009
Posts: 292
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I already tried mature and exasperated behavior to no avail. Didn't have much hope for childish, but it did lift my spirits a bit which is always a plus.

Anyway, this thread is really outdated or just full of bad code. I've managed to clean it up a little but still can not get the tab to show via its AJAX call. Going to the tab via direct link shows up fine. It's weird. Has anybody got this working yet? I'd assume so.
Reply With Quote
Reply

Thread Tools

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 12:38 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.05117 seconds
  • Memory Usage 2,352KB
  • 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
  • (3)bbcode_php
  • (4)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
  • (4)pagenav_pagelink
  • (11)post_thanks_box
  • (1)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
  • (1)postbit_attachment
  • (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_attachment
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete