vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 4 Articles (https://vborg.vbsupport.ru/forumdisplay.php?f=242)
-   -   [HOW TO - vB4] Adding a New Tab in Member Profile (https://vborg.vbsupport.ru/showthread.php?t=235860)

Dylanblitz 02-13-2010 10:00 PM

[HOW TO - vB4] Adding a New Tab in Member Profile
 
1 Attachment(s)
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
https://vborg.vbsupport.ru/attachmen...1&d=1266180760

Sarcoth 02-15-2010 08:02 PM

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.

ageurtse 02-18-2010 05:24 PM

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

Dylanblitz 02-18-2010 06:21 PM

Quote:

Originally Posted by ageurtse (Post 1985737)
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.

Dylanblitz 02-19-2010 08:16 PM

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.

as7apcool 02-24-2010 09:45 PM

thanks 4 great work !

derfelix 02-28-2010 03:43 AM

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.

Dylanblitz 02-28-2010 04:49 AM

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.

derfelix 02-28-2010 05:16 AM

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'

Dylanblitz 02-28-2010 05:57 AM

Yeah would be nice to have a list of everything. I removed the $show registration from the code, thanks for the input :)


All times are GMT. The time now is 11:58 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01183 seconds
  • Memory Usage 1,768KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_php_printable
  • (5)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete