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