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 :)

losedude 03-14-2010 11:07 PM

How would one add tabs to a custom page instead of profile page?

Dylanblitz 03-15-2010 12:14 AM

I don't remember where I found it but there is a article or mod that shows how to add tabs to a custom page for 3.x that still works for 4.x
I just looked but I couldn't find it this time around, not sure where it's at.

Link14716 03-16-2010 10:39 AM

You forgot to mention that you should cache the templates used by making a plugin on the hook cache_templates containing:
PHP Code:

if (THIS_SCRIPT == 'member') {
    
$cache[] = 'my_data_tab';
    
$cache[] = 'my_data_data';


Pretty good guide otherwise.

Dylanblitz 03-17-2010 06:06 AM

Quote:

Originally Posted by Link14716 (Post 2004702)
You forgot to mention that you should cache the templates used by making a plugin on the hook cache_templates containing:
PHP Code:

if (THIS_SCRIPT == 'member') {
    
$cache[] = 'my_data_tab';
    
$cache[] = 'my_data_data';


Pretty good guide otherwise.

Thanks, I didn't think about the cache, I added it :)

Leonard 05-01-2010 04:47 PM

Hey....thanks for the tutorial. Very useful!

Just one question for anyone out there who may know if this is possible. I'm trying to link directly to a tab in the member.php. By default, it will always load up the first tab. I want it to load a specific tab. How would I do this? If it is possible?

Leonard

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

Worked it out...

You can move the hook to member_complete and manually set the $selected_tab variable to make it select your custom tab.

mokujin 05-01-2010 05:11 PM

Do you know how to load the tab as AJAX like facebook? :) THanks

identitas 05-24-2010 07:47 PM

Quote:

Originally Posted by Leonard (Post 2030155)
manually set the $selected_tab variable to make it select your custom tab.

How do i do that?

Vaupell 08-13-2010 07:17 PM

tx, worked in first go..

jeejuh 09-09-2010 12:36 AM

Quote:

Originally Posted by identitas (Post 2042819)
How do i do that?


Change the first plugin to...

Hook Location: member_complete
Plugin Code - vb4.0.2
PHP Code:

$selected_tab "test";

$templater vB_Template::create('my_data_tab'); 
$templater->register('selected_tab'$selected_tab); 
$templater->register('relpath'$relpath); 
$template_hook['profile_tabs_last'] .= $templater->render(); 


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


$templater vB_Template::create('my_data_data'); 
$templater->register('selected_tab'$selected_tab); 
$templater->register('new_user_data'$new_user_data); 
$template_hook['profile_tabs'] .= $templater->render(); 


gurler 11-01-2010 05:35 PM

is it possible to move ALBUM widget to the tabs ?

Dylanblitz 11-04-2010 08:59 AM

Quote:

Originally Posted by gurler (Post 2116831)
is it possible to move ALBUM widget to the tabs ?

I don't see why not. You could find the album code and replicate how they do it with plugins.

I can't look at it right now though, trying to figure out what css changes they made in 4.0.8 that makes non default tabs look jacked up.

noppid 11-04-2010 06:09 PM

Quote:

Originally Posted by Dylanblitz (Post 2117801)
I don't see why not. You could find the album code and replicate how they do it with plugins.

I can't look at it right now though, trying to figure out what css changes they made in 4.0.8 that makes non default tabs look jacked up.

There's a tracker entry about it. http://tracker.vbulletin.com/browse/VBIV-9832

I'm hoping that they will implement the suggestions from DP if enough people vote. (I have no clue how that works.) Otherwise we have to bloat mods with an added template for css and a hook.

Dylanblitz 11-05-2010 06:26 PM

Quote:

Originally Posted by noppid (Post 2117987)
There's a tracker entry about it. http://tracker.vbulletin.com/browse/VBIV-9832

I'm hoping that they will implement the suggestions from DP if enough people vote. (I have no clue how that works.) Otherwise we have to bloat mods with an added template for css and a hook.

Yeah, hopefully they take the suggestion and implement it. I changed the code, it adds 2 templates if it's something you distribute. Otherwise you can do it still with 2 templates and 2 plugins.

Might not be the best way but it's how I got it to work heh.

Hall of Famer 11-12-2010 07:01 AM

looks really cool, oh btw do you know if its possible to add iframes tags in members new profile tabs so that it links to an external site of mine without directing users away from the forum? If so, can you please show me an example of how to do this?

Dylanblitz 11-12-2010 05:43 PM

Quote:

Originally Posted by Hall of Famer (Post 2120844)
looks really cool, oh btw do you know if its possible to add iframes tags in members new profile tabs so that it links to an external site of mine without directing users away from the forum? If so, can you please show me an example of how to do this?

Should be fairly easy. I would put this in your plugin code. Replace the red text with your link.

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 = "<iframe src=\"http://www.yoursite.com/your_page.html\" width=\"550\" height=\"500\" frameborder=\"0\">\n";
$new_user_data .= "<a href=\"http://www.yoursite.com/your_page.html\" target=\"ResourceWindow\">Your browser doesn't support iframe content.\n";
$new_user_data .= "Click here to go directly to included content.</a>\n";
$new_user_data .= "</iframe>\n";

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();
    }


Hall of Famer 11-13-2010 10:04 PM

Thank you so much for this reply, I will give a try on my forum soon. ^^

FreshFroot 12-01-2010 06:05 PM

Anyone got this working for 3.8.x?

Lynne 12-01-2010 06:46 PM

Quote:

Originally Posted by FreshFroot (Post 2128051)
Anyone got this working for 3.8.x?

There is an article in the vB3 forum for this for 3.8.x. It's by Calorie.

Hippy 12-04-2010 01:25 AM

Quote:

Originally Posted by noppid (Post 2117987)
There's a tracker entry about it. http://tracker.vbulletin.com/browse/VBIV-9832

I'm hoping that they will implement the suggestions from DP if enough people vote. (I have no clue how that works.) Otherwise we have to bloat mods with an added template for css and a hook.

thanks for the info ..

this has bothered me since vb4.0.8 came out ..

prevented me from upgrading ..
lol

I just couldn't do it

I may now tho after seeing that bug reported

thanks to all that help here at vb.org
your all much appreciated

hurricane_sh 12-31-2010 01:02 PM

Anyone tried this on VB 4.1.0? My tab was added successfully, but the content is blank. I can find the content in the browser source file, but it doesn't show in the tab.

Edit: never mind, I had a typo.

BirdOPrey5 01-10-2011 12:33 AM

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.

computer22 04-09-2011 09:18 PM

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)

http://images.glua.info/?di=113023873364

Does anyone know what could cause that?

cellarius 05-23-2011 02:04 PM

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.

Pandemikk 06-14-2011 02:34 AM

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.

cellarius 06-14-2011 05:15 AM

Have you seen my post directly over yours?

Pandemikk 06-14-2011 06:20 AM

Yes, I used your PHP code for the plugin and the my_data_data_408 for the template.

Pandemikk 06-15-2011 03:32 PM

Really need some help with this. It's driving me nuts that vB still hasn't a decent article on these member profile tabs.

Pandemikk 06-20-2011 04:24 AM

++++ you +++++++ then.

cellarius 06-20-2011 06:54 AM

I'm sure that this childish behaviour is going to get you LOTS of help.

Pandemikk 06-20-2011 05:43 PM

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.


All times are GMT. The time now is 11:41 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.02927 seconds
  • Memory Usage 1,884KB
  • 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
  • (1)bbcode_code_printable
  • (6)bbcode_php_printable
  • (14)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (40)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