Go Back   vb.org Archive > vBulletin Article Depository > Read An Article > vBulletin 3 Articles
FAQ Community Calendar Today's Posts Search

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
  #62  
Old 09-01-2008, 09:39 PM
milla da killa milla da killa is offline
 
Join Date: Jul 2008
Posts: 25
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Code:
$blocklist = array_merge($blocklist, array(
	'playlist' => array(
		'class' => 'Playlist',
		'title' => 'Playlist',
		'hook_location' => 'profile_left_last'
	)
));

class vB_ProfileBlock_playlist extends vB_ProfileBlock
{
	var $template_name = 'memberinfo_block_playlist';

	function confirm_empty_wrap()
	{
		return false;
	}

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

	function prepare_output($id = '', $options = array())
	{
		$this->block_data['playlist'] = '<div style="text-align: center; margin-left: auto; visibility:visible; margin-right: auto; width:450px;"><embed style="width:435px; visibility:visible; height:270px;" allowScriptAccess="never" src="http://www.greatprofilemusic.com/mc/mp3player-othersite.swf?config=http://www.greatprofilemusic.com/mc/config/config_black_shuffle.xml&mywidth=435&myheight=270&playlist_url=http://www.greatprofilemusic.com/loadplaylist.php?playlist='$this->profile->userinfo[field7]'" menu="false" quality="high" width="435" height="270" name="mp3player" wmode="transparent" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" border="0"/> </div>';
	}
}
I've tried everything, anyone got any suggestions?
Reply With Quote
  #63  
Old 09-10-2008, 06:05 AM
Darkwaltz4's Avatar
Darkwaltz4 Darkwaltz4 is offline
 
Join Date: Oct 2002
Location: Chicago
Posts: 1,538
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

heh, what would be stellar is a tutorial on creating your own fancy tab thing on other pages
Reply With Quote
  #64  
Old 09-22-2008, 09:31 PM
jgeorge123 jgeorge123 is offline
 
Join Date: Apr 2007
Posts: 4
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hi there and i am trying to, i am not that good at describing the code but what i am trying acheive is that - i need to get some data from a the database and show in one of the block. Have a look at my code

PHP Code:
$blocklist array_merge($blocklist, array( 
    
'games' => array( 
        
'class' => 'games'
        
'title' => 'gamess'
        
'hook_location' => 'profile_left_last' 
    

)); 

// ######################### REQUIRE BACK-END ############################ 
require_once('./global.php'); 
global 
$vbulletin
class 
vB_ProfileBlock_games extends vB_ProfileBlock 

    var 
$template_name 'memberinfo_block_games'

    function 
confirm_empty_wrap() 
    { 
        return 
false
    } 

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

    function 
prepare_output($id ''$options = array()) 
    { 
        function 
sql_most_downloaded ($limit
        { 
            global 
$vbulletin$vbphrase
            
$sql $db->query 
                

                    
'SELECT * FROM xxx Where xxx = 'xxx'
                    GROUP BY xxx 
                    ORDER BY xxx DESC 
                    LIMIT x,x' 
                
); 
            while (
$games $db->fetch_array($sql)) 
                { 
                    
$out.= '<li><a href="../games/gamess/show/' $games[ID] . '" title="' $games[file_title] . '">' $games[file_title] . ' [ ' $games[total_downloads] . ' ]</a></li>'
                } 
        } 

        
$this->block_data['games'] = $out
    } 

This selection of data is not based on the vbulletin so i think i can't use
PHP Code:
this->something->something 
Has anyone have any suggestion
Reply With Quote
  #65  
Old 09-29-2008, 09:15 PM
CypherSTL CypherSTL is offline
 
Join Date: Mar 2006
Location: St. Charles, MO
Posts: 306
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Is anyone else having the problem of custom profile tabs not parsing BB Code?

It displays normal HTML correctly, but not BBCode.
Attached Images
File Type: jpg noBBcode.JPG (35.5 KB, 0 views)
Reply With Quote
  #66  
Old 10-27-2008, 03:26 AM
jerx jerx is offline
 
Join Date: Feb 2006
Posts: 188
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I am trying to output pictures from coppermine gallery in a tab. There is a script for coppermine gallery called cpmfetch, which allows to display any picture of your coppermine gallery on external pages. All you need to do is put this into your php page:

PHP Code:
<?php
 
require_once "./coppermine_gallery/cpmfetch/cpmfetch.php";
 
$objCpm = new cpm("./coppermine_gallery/cpmfetch/cpmfetch_config.php");
$objCpm->cpm_viewLastAddedMedia(1,1,$options);
 
$objCpm->cpm_close();
?>
This will add the following code to that page location, which represents the last picture added to your coppermine gallery:

Code:
<table  >

<tr>

<td><a href='http://your_domain.com/coppermine_gallery/thumbnails.php?album=14' ><img src="http://your_domain.com/coppermine_gallery/albums_directory/categoryname/picture_name.jpg" /></a></td>

</tr>


</table>
When I add the following code for my profile tab, that picture will be shown at the very beginning of the profile page - even before doctype, header and body tags.

Code:
$blocklist = array_merge($blocklist, array(
	'copperminegallery' => array(
		'class' => 'CoppermineGallery',
		'title' => 'Last Added Pic',
		'hook_location' => 'profile_left_last'
	)
));

class vB_ProfileBlock_CoppermineGallery extends vB_ProfileBlock
{
	var $template_name = 'memberinfo_block_copperminegallery';

	function confirm_empty_wrap()
	{
		return false;
	}

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

	function prepare_output($id = '', $options = array())
	{
include "./coppermine_gallery/cpmfetch/cpmfetch.php";
$objCpm = new cpm("./coppermine_gallery/cpmfetch/cpmfetch_config.php");
		$this->block_data['copperminegallery'] = $objCpm->cpm_viewLastAddedMedia(1,1,$options);
	}
}
When I add the resulting html code manually into the block it works fine:

Code:
$blocklist = array_merge($blocklist, array(
	'copperminegallery' => array(
		'class' => 'CoppermineGallery',
		'title' => 'My Favs',
		'hook_location' => 'profile_left_last'
	)
));

class vB_ProfileBlock_CoppermineGallery extends vB_ProfileBlock
{
	var $template_name = 'memberinfo_block_copperminegallery';

	function confirm_empty_wrap()
	{
		return false;
	}

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

	function prepare_output($id = '', $options = array())
	{
include "./gallery/cpmfetch/cpmfetch.php";
$objCpm = new cpm("./gallery/cpmfetch/cpmfetch_config.php");
		$this->block_data['copperminegallery'] = '<table  >

<tr>

<td><a href=\'http://your_domain.com/coppermine_gallery/thumbnails.php?album=14\' ><img src="http://your_domain.com/coppermine_gallery/albums_directory/categoryname/picture_name.jpg" /></a></td>

</tr>


</table>
';
	}
}
I had to put a backslash in front of ' to avoid the following error. But I don' t think that this is the problem, because there is no error with the real code.

Quote:
Parse error: syntax error, unexpected T_STRING in /path/to/your/web/root/member.php(454) : eval()'d code on line 250
Does anyone know how to correct the display problem?

Thank you!
Reply With Quote
  #67  
Old 11-17-2008, 09:16 AM
Wordplay Wordplay is offline
 
Join Date: Nov 2001
Location: Dengoku
Posts: 864
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

great! thanks a lot!

is there a way to have a preview of the latest threads and posts made by a user the way they have it on ipb in those tabs:
http://forums.invisionpower.com/inde...showuser=75430

i actually requested that as a mod:
https://vborg.vbsupport.ru/showthread.php?t=196487
Reply With Quote
  #68  
Old 11-18-2008, 09:02 PM
Bilderback's Avatar
Bilderback Bilderback is offline
 
Join Date: Sep 2007
Location: Illinois
Posts: 214
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Great Article.
Code:
'hook_location' => 'profile_left_last'
Does anyone know how to provide the hook location when defined by the admincp?
My product has setting options like seen below:
Code:
<setting varname="custom_hook_location" displayorder="20">
    <datatype>free</datatype>
    <optioncode><![CDATA[select:piped
0|None
1|$template_hook[profile_left_first]
2|$template_hook[profile_left_last]
]]></optioncode>
    <defaultvalue>0</defaultvalue>
</setting>
I am trying to display the block from whichever is chosen in admincp.
Have tried the following with no luck-
custom_hook_location
$vbulletin->options['custom_hook_location']

Thanks
Reply With Quote
  #69  
Old 11-22-2008, 11:22 AM
fabs_pim fabs_pim is offline
 
Join Date: Jul 2008
Posts: 4
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

How do I display a list which i want to get out of an mysql database in such a profile tab?
Reply With Quote
  #70  
Old 11-22-2008, 03:45 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by fabs_pim View Post
How do I display a list which i want to get out of an mysql database in such a profile tab?
You'll need to add your query into the plugin and then spit the results out into "$this->block_data['mymodification']"
Reply With Quote
  #71  
Old 01-25-2009, 06:37 AM
DragonBlade's Avatar
DragonBlade DragonBlade is offline
 
Join Date: May 2006
Posts: 189
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hey, I'm trying to test this out and see if I can make something cool for my members, but I've noticed something a bit weird...

For the template, I've got the following code:
Code:
<if condition="$vbulletin->userinfo['userid'] == 15010">
<div class="alt1 block_row">
	<ul class="list_no_decoration">
		$block_data[animelist]
	</ul>
</div>
</if>
The conditional is there because, as I said, I'm testing it out and don't want all my members to see it yet, just me. However, after not getting it to display and a bit of tinkering around, I've found out that the $vbulletin object does not exist as far as the template is concerned. I've tried these variations to be sure:
Code:
<if condition="$vbulletin->userinfo['userid'] == 15010">
<if condition="$vbulletin->userinfo['userid']">
<if condition="$vbulletin->userinfo">
<if condition="$vbulletin">
<if condition="1">
The last one DID work, of course.

How would I make it so that the $vbulletin object IS recognized?




EDIT: BTW, I did "solve" it simply by putting the plugin itself in some "IF" brackets, but still for curiosity's sake, let's say for some reason I wanted to use the $vbulletin object in the tab (maybe I wanted to make a Tab with the User's name or something equally silly).
Reply With Quote
Reply


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 07:28 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.05111 seconds
  • Memory Usage 2,374KB
  • 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
  • (13)bbcode_code
  • (3)bbcode_php
  • (2)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
  • (1)postbit_attachment
  • (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
  • postbit_attachment
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete