Go Back   vb.org Archive > vBulletin Article Depository > Read An Article > vBulletin 4 Articles
[vB4] Add new Tab at User's Profile and make it preselected
TheAdminMarket's Avatar
TheAdminMarket
Join Date: Jun 2013
Posts: 511

 

Thessaloniki, Greece
Show Printable Version Email this Page Subscription
TheAdminMarket TheAdminMarket is offline 10-18-2014, 10:00 PM

Hello,

Important: This Article will shows you the way to create your own tab in user's Profile page, set it as first or last, and if you want, make it preselected. If you already have the tabs (custom or vB default) and the only that you want is to change the default Activity tab to another tab, then Ozzy47 has released a nice and easy addon. You can find it here.

If you want to build your own tab the steps that you must follow are listing below. for easy convertion we assume that your tab name is: mytabname

1.- Create a New Plugin:

a] Name: My Profile Tab
b] Hook Location: member_complete
c] Plugin PHP code:
PHP Code:
global $vbulletin
require_once(
DIR '/includes/class_postbit.php'); 
require_once(
DIR '/includes/functions_user.php'); 
if (isset(
$vbulletin->GPC['tab'])) 

    
$selected_tab $vbulletin->GPC['tab']; 

$blockinfo['title'] = 'My Tab'
$blockid "mytabname"
$taburl $memberurl fetch_seo_url('member'$prepared) . "&tab=mytabname#mytabname"
// Drawing the Tab 
$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_first'] .= $templater->render(); 
Comments:

1.- You can use a Global phrase for $blockinfo['title']. For example:
Code:
$blockinfo['title'] = $vbphrase["my_global_phrase"];
2.- You can choose the position of your tab. In my code above the tab will appears first of all. If you want it at the end, use as template hook: profile_tabs_last

The code above draws only the tab. Nothing more. To add content we must extend the php code and also use a template for it. Let's continue with the PHP code. Should be on the same code block above. No different plugin !!

PHP Code:
// Here you can add your PHP code for querying the database, assigning variables etc

// This is the setup for the tab template
$templater vB_Template::create('my_profile_tab_template');
$templater->register('selected_tab'$selected_tab);
$templater->register('userinfo'$userinfo[userid]);
$templater->register('userid'$userinfo[userid]);       

// Here you must assign all variables to be used in the template
     
$template_hook['profile_tabs'] .= $templater->render(); 
Now click Save and you finished with the first step. Let's continue:

2.- Create your template.

There are many articles teaching how to create a template. Here I'll show you only the data that this template must has. Don't forget to use the same template name. In our example is: my_profile_tab_template

HTML Code:
<div id="view-mytabname" class="<vb:if condition="$selected_tab == 'mytabname'">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">My Header Title goes here</h4>
    </div>
    // Real tab content goes here
</div>
3.- Cache the template

You must create a new Plugin for caching the template. Use the example data below:

a] Name: My Tab Template Cache
b] Hook Location: cache_templates
c] PHP code:
PHP Code:
if (THIS_SCRIPT == 'member')
{
    
$cache array_merge($cache, array(
           
'my_profile_tab_template',
     ));

4.- Make Tab preselected (Optional)

If you want to make your tab preselected which means that from any link that someone will clicks to see user's profile, your tab should be the first in view (default is the Activity tab), add one more plugin:

a] Name: My Tab Preselected
b] Hook Location: member_build_blocks_start
c] PHP code:
Code:
$vbulletin->GPC['tab'] = 'mytabname';
Reply With Quote
Reply

Thread Tools

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 03:10 PM.


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.05815 seconds
  • Memory Usage 2,207KB
  • Queries Executed 14 (?)
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_code
  • (1)bbcode_html
  • (3)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_article
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (1)post_thanks_box
  • (2)post_thanks_box_bit
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (1)post_thanks_postbit_info
  • (1)postbit_onlinestatus
  • (1)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_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete