Go Back   vb.org Archive > vBulletin Article Depository > Read An Article > vBulletin 3 Articles

Reply
 
Thread Tools
[How-to] Add more tabs to the vB 3.7 profile pages
calorie
Join Date: May 2003
Posts: 2,804

 

Show Printable Version Email this Page Subscription
calorie calorie is offline 12-18-2007, 10:00 PM

If you want to add more tabs to the vB 3.7 profile pages, assuming JavaScript is enabled, or more blocks if JavaScript is off, then this tutorial is for you. If you like to learn in a trial by fire sort of way, create a new template titled memberinfo_block_mymodification with the following content:
Code:
<div class="alt1 block_row">
	<ul class="list_no_decoration">
		$block_data[mymodification]
	</ul>
</div>
Add a new plugin to the member_build_blocks_start hook with the following PHP code:
Code:
$blocklist = array_merge($blocklist, array(
	'mymodification' => array(
		'class' => 'MyModification',
		'title' => 'My Modification',
		'hook_location' => 'profile_left_last'
	)
));

class vB_ProfileBlock_MyModification extends vB_ProfileBlock
{
	var $template_name = 'memberinfo_block_mymodification';

	function confirm_empty_wrap()
	{
		return false;
	}

	function confirm_display()
	{
		return ($this->block_data['mymodification'] != '');
	}

	function prepare_output($id = '', $options = array())
	{
		$this->block_data['mymodification'] = 'Content to show in the tab.';
	}
}
Now visit your profile page to test it out. You should see a 'My Modification' tab that when clicked shows you the following text: Content to show in the tab. Exciting huh? Of course you need to add your own custom code for what to display, but this tutorial isn't about that, but rather to show you how to add tabs to the profile pages.

If you want to learn a bit more of the details, first consider this part:
Code:
$blocklist = array_merge($blocklist, array(
	'mymodification' => array(
		'class' => 'MyModification',
		'title' => 'My Modification',
		'hook_location' => 'profile_left_last'
	)
));
The $blocklist variable contains the default blocks. You merge to that another array where the key 'mymodification' references an array which sets a class to use, the title of the tab on the profile page, and the hook location. You can set whatever you want for title including the use of $vbphrase but in the example 'My Modification' is used. As for the hook location, you can use profile_left_first or profile_left_last depending on whether you want your new tab to be left or right of the current tabs, respectively.

Next consider the next part:
Code:
class vB_ProfileBlock_MyModification extends vB_ProfileBlock
{
	var $template_name = 'memberinfo_block_mymodification';

	function confirm_empty_wrap()
	{
		return false;
	}

	function confirm_display()
	{
		return ($this->block_data['mymodification'] != '');
	}

	function prepare_output($id = '', $options = array())
	{
		$this->block_data['mymodification'] = 'Content to show in the tab.';
	}
}
The class needs to be called vB_ProfileBlock_MyModification extends vB_ProfileBlock and note that part of the class name is vB_ProfileBlock_MyModification where MyModification comes from the class value set in your addition to the $blocklist variable. Inside the class, $template_name is set to the template to use, the confirm_empty_wrap function returns false to not create an empty block, the confirm_display function tests whether there is any content to display, and the prepare_output function is where you?d want to add your own custom code to fetch whatever you want to display, setting $this->block_data['mymodification'] to the content you want displayed. Remember variable scope when you add your own code, as you are inside a function that is inside a class.

Now there is the new template itself:
Code:
<div class="alt1 block_row">
	<ul class="list_no_decoration">
		$block_data[mymodification]
	</ul>
</div>
Note that $block_data[mymodification] contains whatever $this->block_data['mymodification'] contains in the prepare_output function inside the class, and because a hook location is set in your addition to the $blocklist variable, there are no manual template edits to make. Hooray! You should of course replace 'mymodification', 'MyModification', and 'My Modification' throughout this tutorial with something meaningful for your modification.

Finally there are other things that can be added to modifications such as options, and these can be seen in the vB class_profileblock.php and member.php files, though this tutorial should get you on your way to adding more content to the profile pages via additional tabs, but remember not to go overboard with queries, because even though you need to click the tab to see the content, whatever queries you run get run on page load, not tab click. Enjoy!

Fine print: tutorial based on vB 3.7.0 Beta 2, no redistribution without permission.
Reply With Quote
  #22  
Old 03-26-2008, 12:47 PM
rob30UK rob30UK is offline
 
Join Date: Oct 2005
Location: UK
Posts: 159
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I can get the tab to show custom profile fields, but i want the same fields to be removed from the about me section - how would this be achieved?
Reply With Quote
  #23  
Old 03-27-2008, 05:01 AM
TWTCommish's Avatar
TWTCommish TWTCommish is offline
 
Join Date: Oct 2001
Location: Pittsburgh, PA, USA
Posts: 783
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This is quite helpful. Is there any way to add dynamic content to the tab, however? I've tried everything I can think of to achieve this, but the scope of the class won't allow for it. Is this method relegated to static content, or can this be done?
Reply With Quote
  #24  
Old 03-29-2008, 01:35 PM
Blackhat's Avatar
Blackhat Blackhat is offline
 
Join Date: Mar 2005
Posts: 323
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Im using this in my plugin, but the tab disappeared

Code:
	function prepare_output($id = '', $options = array())
	{
		$this->block_data['custom'] = $this->profile->userinfo['field17'] : "Stuff: $this->profile->userinfo['field17']" ? "Nothing to see here";
	}
--------------- Added [DATE]1206807291[/DATE] at [TIME]1206807291[/TIME] ---------------

ok I got it working with this code, but it looks like it wont custom html by my users like this

Code:
$blocklist = array_merge($blocklist, array(
    'customcode' => array(
        'class' => 'CustomCode',
        'title' => 'My Media',
        'hook_location' => 'profile_left_last'
    )
));

class vB_ProfileBlock_CustomCode extends vB_ProfileBlock
{
    var $template_name = 'memberinfo_block_customcode';

    function confirm_empty_wrap()
    {
        return false;
    }

    function confirm_display()
    {
        return ($this->block_data['customcode'] != '');
    }

    function prepare_output($id = '', $options = array())
    {
        $this->block_data['customcode'] = $this->profile->userinfo['field17'];
    }
}
I want my users to insert the embed code for their playlists generated at youtube
Reply With Quote
  #25  
Old 03-30-2008, 09:02 PM
SEOvB's Avatar
SEOvB SEOvB is offline
 
Join Date: May 2007
Location: Indianapolis
Posts: 2,451
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

How would i add a custom template to be put inside the block?
Reply With Quote
  #26  
Old 04-05-2008, 04:55 PM
Peterpan002 Peterpan002 is offline
 
Join Date: Jan 2008
Location: United Kingdom
Posts: 76
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

A very helpful article thank you, just not quite enough help for non coders like me.

I successfully created new tab and with the following code I now get output of "field 12" showing but not "field 11" instead of both showing, am also having difficulty inserting the field title in the output. A little help maybe.

Code:
$blocklist = array_merge($blocklist, array(
	'checklist' => array(
		'class' => 'checklist',
		'title' => 'Checklist (Work in Progress)',
		'hook_location' => 'profile_left_last'
	)
));

class vB_ProfileBlock_checklist extends vB_ProfileBlock
{
	var $template_name = 'memberinfo_block_checklist';

	function confirm_empty_wrap()
	{
		return false;
	}

	function confirm_display()
	{
		return ($this->block_data['checklist'] != '');
	}

	function prepare_output($id = '', $options = array())
    {
        $this->block_data['checklist'] = $this->profile->userinfo['field11'];


        $this->block_data['checklist'] = $this->profile->userinfo['field12'];
    }



}
--------------- Added [DATE]1207495466[/DATE] at [TIME]1207495466[/TIME] ---------------

I would really appreciate a little help with this as its so close to working fully - Bump
Reply With Quote
  #27  
Old 04-09-2008, 11:51 AM
Makc666's Avatar
Makc666 Makc666 is offline
 
Join Date: Dec 2002
Location: MSK-RU
Posts: 392
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Peterpan002 View Post
I successfully created new tab and with the following code I now get output of "field 12" showing but not "field 11" instead of both showing, am also having difficulty inserting the field title in the output. A little help maybe.

I would really appreciate a little help with this as its so close to working fully - Bump
This one:
Code:
function prepare_output($id = '', $options = array())
    {
        $this->block_data['checklist'] = $this->profile->userinfo['field11'];


        $this->block_data['checklist'] = $this->profile->userinfo['field12'];
    }
}
To this one:
Code:
function prepare_output($id = '', $options = array())
    {
        $this->block_data['checklist'] = $this->profile->userinfo['field11'];
        $this->block_data['checklist'] .= $this->profile->userinfo['field12'];
    }
}
--------------- Added [DATE]1207746300[/DATE] at [TIME]1207746300[/TIME] ---------------

My question here...

In vBulletin 3.6.* I had such code in product:
Code:
<plugin active="1" executionorder=5" product="test">
<title>Test - member complete</title>
<hookname>member_complete</hookname>
<phpcode><![CDATA[if (THIS_SCRIPT == 'member')
{
	$test = "Hellow!";
	if ($vbulletin->options[test_auto])
		{
			$footer = $test.$footer;
		}
}]]></phpcode>
</plugin>
Question: How to add $test to the new tab?

This one doesn't work:
Code:
	function prepare_output($id = '', $options = array())
	{
		$this->block_data['test'] = "$test";
	}
Reply With Quote
  #28  
Old 04-09-2008, 03:21 PM
Peterpan002 Peterpan002 is offline
 
Join Date: Jan 2008
Location: United Kingdom
Posts: 76
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you Makc666.

Moving on LOL. New Tab is now outputting what I want.

Next issue and I'm sure others need to know this as well.

On the "About tab" is the option "simple link" - View your "About Me" as seen by everyone else. situated on the left which calls member.php?u=1&tab=aboutme&simple=1

I have reproduced this on my new tab which calls member.php?u=1&tab=newtab&simple=1

exept it doesnt it just reloads the main memberinfo page.

Any pointers???
Reply With Quote
  #29  
Old 04-09-2008, 07:26 PM
Makc666's Avatar
Makc666 Makc666 is offline
 
Join Date: Dec 2002
Location: MSK-RU
Posts: 392
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Peterpan002 View Post
Next issue and I'm sure others need to know this as well.

On the "About tab" is the option "simple link" - View your "About Me" as seen by everyone else. situated on the left which calls member.php?u=1&tab=aboutme&simple=1

I have reproduced this on my new tab which calls member.php?u=1&tab=newtab&simple=1

exept it doesnt it just reloads the main memberinfo page.

Any pointers???
Show the code you are speaking about.
The code that you had added.
Reply With Quote
  #30  
Old 04-09-2008, 09:10 PM
Peterpan002 Peterpan002 is offline
 
Join Date: Jan 2008
Location: United Kingdom
Posts: 76
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

My Custom template called for the tab

Code:
<div class="alt1 block_row" align="right">

<if condition="$show['simple_link']">
	<div id="simple_experience"><a class="smallfont" href="member.php?$session[sessionurl]u=$bbuserinfo[userid]&amp;tab=experience&amp;simple=1">$vbphrase[view_your_extra_options]</a></div>
</if>
<if condition="$show['edit_link']">
	<div id="simple_experience_link"><a class="smallfont" href="member.php?$session[sessionurl]u=$bbuserinfo[userid]&amp;tab="profile_left_last">$vbphrase[edit_extra_options]</a></div>
</if>



<div class="alt1 block_row" align="left">

<ul class="list_no_decoration">
	$block_data[experience]
	
		<!-------------------------Extra option profile fields-------->

<dt class="shade" id="profilefield_title_$profilefield[profilefieldid]">$profilefield[title]</dt>

<br>
<if condition="$userinfo[field11]">Field Title 11 $userinfo[field11]<br /></if>

<br>
<if condition="$userinfo[field12]">Field Title 12  $userinfo[field12]<br /></if>

<br>
<if condition="$userinfo[field14]">Field Title 14 $userinfo[field14]<br /></if>

<br>
<if condition="$userinfo[field13]">Field Title 13 <br> $userinfo[field13]<br /></if>

<br>

<if condition="$userinfo[field15]">Field Title 15 </if>
<if condition="$comma = ''"></if>

<if condition="$userinfo['field15'] & 1">
	$comma Option A
	<if condition="$comma = ', '"></if>
</if>
<if condition="$userinfo['field15'] & 2">
	$comma Option B
	<if condition="$comma = ', '"></if>
</if>
<if condition="$userinfo['field15'] & 4">
	$comma Option C
	<if condition="$comma = ', '"></if>
</if>
<if condition="$userinfo['field15'] & 8">
	$comma Option D
	<if condition="$comma = ', '"></if>
</if>
<if condition="$userinfo['field15'] & 16">
	$comma Option E
	<if condition="$comma = ', '"></if>
</if>

<br>
<br>
<if condition="$userinfo[field16]">My Yes/No answer is: $userinfo[field16]<br /></if>

<br>
<if condition="$userinfo[field17]">My Selection Menu Choice is: $userinfo[field17]<br /></if>

			
						
</ul>
</div>
</div>
and the "Member_build_blocks_start plug in code to call template


Code:
$blocklist = array_merge($blocklist, array(
	'checklist' => array(
		'class' => 'experience',
		'title' => 'My Experience',
		'hook_location' => 'profile_left_last'
	)
));

class vB_ProfileBlock_experience extends vB_ProfileBlock
{
	var $template_name = 'memberinfo_block_experience';

	function confirm_empty_wrap()
	{
		return false;
	}

	function confirm_display()
	{
		return ($this->block_data['experience'] != '');
	}

	function prepare_output($id = '', $options = array())
	{
		$this->block_data['experience'] = 'My Experience:';


	}


}
Reply With Quote
  #31  
Old 04-10-2008, 01:43 PM
Makc666's Avatar
Makc666 Makc666 is offline
 
Join Date: Dec 2002
Location: MSK-RU
Posts: 392
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Peterpan002 View Post
My Custom template called for the tab
Sorry, but I was not able to display your template.
It always show we blank.
You can upload a ready test product for us to try if you want.
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 09:10 AM.


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.05803 seconds
  • Memory Usage 2,335KB
  • Queries Executed 26 (?)
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
  • (14)bbcode_code
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_article
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (11)post_thanks_box
  • (1)post_thanks_box_bit
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete