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
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
  #2  
Old 02-15-2010, 08:02 PM
Sarcoth Sarcoth is offline
 
Join Date: Mar 2006
Location: Huntsville
Posts: 521
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you. I do a lot of stuff with custom profiles and this code is nice to have.

/subscribed.

I'll now look into seeing how I can get certain profilefields to appear on the new tab.
Reply With Quote
  #3  
Old 02-18-2010, 05:24 PM
ageurtse ageurtse is offline
 
Join Date: Apr 2009
Location: almelo
Posts: 275
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

is this article written for the latest vb 4.0.2 or is this for a different version ?

i now had my mod working on vb 4.0.1 and on vb 4.0.2 this mod is working but on every tab there is a link of the tab.

so if your solution works on 4.0.2 i have to rewrite my mod

i don't like it that vbulletin changes on every release the way things should be done.
so a mod can't be use on several version's
Reply With Quote
  #4  
Old 02-18-2010, 06:21 PM
Dylanblitz Dylanblitz is offline
 
Join Date: Oct 2005
Location: OC, California
Posts: 732
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by ageurtse View Post
is this article written for the latest vb 4.0.2 or is this for a different version ?

i now had my mod working on vb 4.0.1 and on vb 4.0.2 this mod is working but on every tab there is a link of the tab.

so if your solution works on 4.0.2 i have to rewrite my mod

i don't like it that vbulletin changes on every release the way things should be done.
so a mod can't be use on several version's
I wrote it on 4.0.0 and had others test on 4.0.1. I haven't downloaded 4.0.2 yet.
I'm going to have to bite the bullet and install it on my production box. 4.0.0 only half works for me on my dev because the CMS wont allow me to use a port other then 80. 4.0.1 doesn't work at all on my dev. I'm sure 4.0.2 will be worse for me heh.
Reply With Quote
  #5  
Old 02-19-2010, 08:16 PM
Dylanblitz Dylanblitz is offline
 
Join Date: Oct 2005
Location: OC, California
Posts: 732
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

ageurtse,
They changed the template hook names. I found the new hooks to use and it works fine on my test system. I updated the code in the original post.
Let me know if you have problems with it. Wish they would at least keep the old ones for a while and let us know they're going to be gone.
Reply With Quote
  #6  
Old 02-24-2010, 09:45 PM
as7apcool as7apcool is offline
 
Join Date: Feb 2009
Posts: 194
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

thanks 4 great work !
Reply With Quote
  #7  
Old 02-28-2010, 03:43 AM
derfelix derfelix is offline
 
Join Date: Nov 2001
Posts: 204
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

very nice.. you saved my day.. !!!
just one thing..
I thought the $show array does NOT need to be registered...
$templater->register('show', $show);
havent tested here yet.. but usually on other pages it does not...

F.
Reply With Quote
  #8  
Old 02-28-2010, 04:49 AM
Dylanblitz Dylanblitz is offline
 
Join Date: Oct 2005
Location: OC, California
Posts: 732
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I wasn't sure, I haven't seen a list of what is auto registered, so I usually just register everything I need in the template.
Reply With Quote
  #9  
Old 02-28-2010, 05:16 AM
derfelix derfelix is offline
 
Join Date: Nov 2001
Posts: 204
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

well as far as I know (assume) ....
(not sure read somewhere, but sorry, cant remember where)
magic globals dont need registering,
like $template_hook, $show, $vboptions, $stylevar, $vbphrase
not sure with $template_hook, but thats easy to test..
there might be others.. would be interesting if someone knew where to find a complete list!!

F.

PS: check class_core.php line: 3959 and following: public function render
$template_hook and $show are 'magic globals'
Reply With Quote
  #10  
Old 02-28-2010, 05:57 AM
Dylanblitz Dylanblitz is offline
 
Join Date: Oct 2005
Location: OC, California
Posts: 732
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yeah would be nice to have a list of everything. I removed the $show registration from the code, thanks for the input
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 10:27 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.04914 seconds
  • Memory Usage 2,339KB
  • 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
  • (2)bbcode_php
  • (5)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
  • (1)post_thanks_box_bit
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (10)post_thanks_postbit_info
  • (9)postbit
  • (1)postbit_attachment
  • (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_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