Register Members List Search Today's Posts Mark Forums Read

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

OC, California
by Dylanblitz Dylanblitz is offline 14 Feb 2010

If you are using anything above vB4.0.8 then refer to cellarius' updated article.
http://www.vbulletin.org/forum/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)
<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)
<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)
<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)
<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

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Second plugin
Hook Location: cache_templates
Title: Whatever you want to call it

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

And the result
Attached Images
File Type: png new_tab.png (6.0 KB, 2102 views)

Last edited by Dylanblitz; 30 Jun 2011 at 04:24.. Reason: Fixed for 4.0.8 changes and consolidation of code
Views: 12323
Reply With Quote
Comments
  #2  
Old 15 Feb 2010, 22:02
Sarcoth Sarcoth is offline
 
Join Date: Mar 2006
Real name: Nick
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 18 Feb 2010, 19:24
ageurtse ageurtse is offline
 
Join Date: Apr 2009
Real name: arnold
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 18 Feb 2010, 20:21
Dylanblitz Dylanblitz is offline
 
Join Date: Oct 2005
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 19 Feb 2010, 22:16
Dylanblitz Dylanblitz is offline
 
Join Date: Oct 2005
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 24 Feb 2010, 23:45
as7apcool's Avatar
as7apcool as7apcool is offline
 
Join Date: Feb 2009
thanks 4 great work !
Reply With Quote
  #7  
Old 28 Feb 2010, 05:43
derfelix derfelix is offline
 
Join Date: Dec 2001
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 28 Feb 2010, 06:49
Dylanblitz Dylanblitz is offline
 
Join Date: Oct 2005
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 28 Feb 2010, 07:16
derfelix derfelix is offline
 
Join Date: Dec 2001
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'

Last edited by derfelix; 28 Feb 2010 at 07:28.
Reply With Quote
  #10  
Old 28 Feb 2010, 07:57
Dylanblitz Dylanblitz is offline
 
Join Date: Oct 2005
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
  #11  
Old 15 Mar 2010, 01:07
losedude losedude is offline
 
Join Date: Dec 2007
How would one add tabs to a custom page instead of profile page?
Reply With Quote
  #12  
Old 15 Mar 2010, 02:14
Dylanblitz Dylanblitz is offline
 
Join Date: Oct 2005
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.
Reply With Quote
  #13  
Old 16 Mar 2010, 12:39
Link14716's Avatar
Link14716 Link14716 is offline
 
Join Date: Jun 2002
Real name: Matthew Gordon
You forgot to mention that you should cache the templates used by making a plugin on the hook cache_templates containing:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Pretty good guide otherwise.
__________________
Along with Zachery, I make releases as GeekyDesigns. Please do not PM or IM me for support.
Reply With Quote
  #14  
Old 17 Mar 2010, 08:06
Dylanblitz Dylanblitz is offline
 
Join Date: Oct 2005
Originally Posted by Link14716 View Post
You forgot to mention that you should cache the templates used by making a plugin on the hook cache_templates containing:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Pretty good guide otherwise.
Thanks, I didn't think about the cache, I added it
Reply With Quote
  #15  
Old 01 May 2010, 18:47
Leonard Leonard is offline
 
Join Date: Dec 2001
How do you link directly to a tab in member.php?

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 01 May 2010 at 19:05 ---------------

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.

Last edited by Leonard; 01 May 2010 at 19:05. Reason: Auto-Merged DoublePost
Reply With Quote
Reply

Similar Article
Article Author Type Replies Last Post
Profile Gallery: Allow Users to Upload Member Profile Images calorie vBulletin 3.6 Add-ons 45 13 Jan 2008 16:18



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Article Options

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


New To Site? Need Help?

All times are GMT. The time now is 06:47.

Layout Options | Width: Wide Color: