The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
[HOW TO - vB4] Adding a New Tab in Member Profile - Reloaded
This tutorial is an update of Dylanblitz' howto for older versions. Credits to him, and thanks for giving me green light for building on his ideas. This has been tested with [S]4.1.4[/S] 4.2,[S] but should work as far back as 4.0.8, when profile customization was reintroduced. [/S] [Explanation: At least with version 4.1.8, the template name convention for profile tabs was changed. If you want to code for an earlier version, use custom_profile_tab_test as template name.] First step To create a new member profile tab, create a plugin at hook member_complete Code:
if (isset($vbulletin->GPC['tab'])) { $selected_tab = $vbulletin->GPC['tab']; } $blockinfo['title'] = "Test Title"; $blockid = "test"; $taburl = $memberurl = fetch_seo_url('member', $prepared) . "&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(); // ### Your code to fill the tab ### // Don't forget you need to register any variables for use in templates $test_tab_content = "Congratulations, you can see me, I'm your PHP Code!"; $templater = vB_Template::create('memberinfo_block_test'); $templater->register('selected_tab', $selected_tab); $templater->register('test_tab_content', $test_tab_content); $template_hook['profile_tabs'] .= $templater->render();
Second step The second step to a custom profile tab is to create a new template. It has to be the name you used in your php code to create it, in our case: memberinfo_block_test. Code:
<div id="view-test" class="<vb:if condition="$selected_tab == 'test'">selected_view_section<vb:else />view_section</vb:if><vb:if condition="$userinfo['userid'] != $bbuserinfo['userid']"> vm_other_prof</vb:if>"> <div class="blocksubhead subsectionhead userprof_headers userprof_headers_border"> <h4 class="subsectionhead-understate">Test</h4> </div> <br />This is a <b>custom tab</b> test.<br /> {vb:raw test_tab_content} </div>
Direct access If you want to access your custom profile tag directly, append &tab=test#testto the profile URL. That's it |
#22
|
|||
|
|||
Any ideas why this only works if "test" is used in the $taburl variable? If I change the #test to #quoted ($blockid var) nothing shows up.
PHP Code:
HTML Code:
<div id="view-quoted" class="<vb:if condition="$selected_tab == 'quoted'">selected_view_section<vb:else />view_section</vb:if><vb:if condition="$userinfo['userid'] != $bbuserinfo['userid']"> vm_other_prof</vb:if>"> <div class="blocksubhead subsectionhead userprof_headers userprof_headers_border"> <h4 class="subsectionhead-understate">Test</h4> </div> <br />This is a <b>custom tab</b> test.<br /> {vb:raw quoted_tab_content} </div> |
#23
|
|||
|
|||
What should I do to have to extra tab only be shown to certain usergroups ?
--------------- Added [DATE]1335389174[/DATE] at [TIME]1335389174[/TIME] --------------- nevermind. figured it out: if (is_member_of($vbulletin->userinfo,x,y,z)) { } in the plugin where x,y,z are the group Id's |
#24
|
|||
|
|||
Alright, so I've got the "Gallery" tab added. Now how would I add the content? How can I add photos?
Also I notice that none of my blog entries are showing up under my "Blog" tab in my user profile. I am logged in and everything. |
#25
|
||||
|
||||
You have the tab working - this is all this article is about.
It is not about querying whatever it is you want to show on that tab. It sure is not about general support issues (your blog tab not working). Please ask for help in your own thread in the proper forums. |
#26
|
|||
|
|||
But the "Congratulations, you can see me, I'm your PHP Code!" is not appearing under the new tab I added.
Can you please help me to determine why? I had deleted some of the code in the memberinfo_block_statistics template and cleared out the code in the memberinfo_block_contactinfo template, because I did not like all of that ("Number of Posts per Day: 0.25" etc) content in my User Profile. |
#27
|
||||
|
||||
If you follow the tutorial by the letter, it will be there. I cannot know what you did wrong.
|
#28
|
|||
|
|||
I copied and pasted the code you showed in my AdminCP, where you told me to.
Was that what I was supposed to do? |
#29
|
||||
|
||||
Article updated. Obviously the template name convention was changed somewhere along the line.
The template needs to be named memberinfo_block_test now (remember to adapt the create_template call in the plugin accordingly. |
#30
|
|||
|
|||
I did it exactly as you have it, but it does the same thing......I'm wondering if it is because I had deleted some of the code in the memberinfo_block_statistics template and cleared out the code in the memberinfo_block_contactinfo template, because I did not like all of that ("Number of Posts per Day: 0.25" etc) content in my User Profile? Could that affect it at all?
|
#31
|
||||
|
||||
You could always try and revert those templates.
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|