[vB4] Add new Tab at User's Profile and make it preselected
by
19 Oct 2014
Rating: (1 vote
- 5.00 average)
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;
1.- You can use a Global phrase for $blockinfo['title']. For example: Code:
$blockinfo['title'] = $vbphrase["my_global_phrase"]; 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
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> 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')
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'; |