The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
[How-to] Add more tabs to the vB 3.7 profile pages
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> 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.'; } } 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' ) )); 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.'; } } Now there is the new template itself: Code:
<div class="alt1 block_row"> <ul class="list_no_decoration"> $block_data[mymodification] </ul> </div> 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. |
#72
|
||||
|
||||
Make $vbulletin global in the plugin.
|
#73
|
|||
|
|||
Ok, this might have been answered before, but it seems I'm doing something wrong. I'm trying to add a new tab and display a custom profile field (field24) in it. Here's my plugin 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'] = $this->profile->userinfo['field24'] : "Stuff: $this->profile->userinfo['field24']" ? "Nothing to see here"; } } } Quote:
|
#74
|
|||
|
|||
Cledus: The ?: is in the wrong order. It should be:
Code:
$this->block_data['mymodification'] = $this->profile->userinfo['field24'] ? "Stuff: $this->profile->userinfo['field24']" : "Nothing to see here"; On another topic, for anyone interested, and to get some feedback on whether this is done properly: I wanted to get mysql data on my new tab, and $db and $vbulletin->db didn't work - they aren't around when this code gets called. In the class_profileblock.php file, when it's building the static blocks such as user statistics and buddy list, it uses this: Code:
$this->registry->db Edit: $this->registry seems to be the same as $vbulletin elsewhere... |
#75
|
|||
|
|||
Quote:
Ok, I updated it and it did fix the error, but it still didn't display the field. It displayed: Quote:
So here's my plugin right now: 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'] = $this->profile->userinfo['field24'] ? "Stuff: $this->profile->userinfo['field24']" : "Nothing to see here"; } } |
#76
|
||||
|
||||
Have you tried to see if your plugin is even working by doing something simple like:
PHP Code:
PHP Code:
|
#77
|
|||
|
|||
Oops, wasn't looking at the rest of the code. Array values need to be appended, can't be parsed inside quotes like a normal $variable:
Code:
$this->block_data['mymodification'] = $this->profile->userinfo['field24'] ? "Stuff: ".$this->profile->userinfo['field24'] : "Nothing to see here"; Code:
$field24=$this->profile->userinfo['field24']; $this->block_data['mymodification'] = $field24 ? "Stuff: $field24" : "Nothing to see here"; (p.s. If people prefer I don't answer questions here, I'll move to PM) |
#78
|
|||
|
|||
Sent you a PM.
|
#79
|
|||
|
|||
Ok, can someone help me just a bit more. Probably just an easy fix.
Now I added the last code posted to my plugin and it worked. It displayed the data from my custom profile field 18. In my above thread I said it was userfield24 but I had it wrong, it's userfield18. Now here's my plugin 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'] = $this->profile->userinfo['field18'] ? "Stuff: ".$this->profile->userinfo['field18'] : "Nothing to see here"; } } 1. List Item 1 2. List Item 2 3. List Item 3 4. List Item 4 etc. Now when its displayed in the new tab it all comes out on the same line like: 1. List Item 1 2. List Item 2 3. List Item 3 4. List Item 4 My question is, is there any way I can get it to be displayed in a list format? Like creating a new line for every list object? I tried adding a BR command in the field input itself without any luck. Anyone know how I can get it displayed like the way I input it into the field? Thank you for any help anyone may offer. --------------- Added [DATE]1234633359[/DATE] at [TIME]1234633359[/TIME] --------------- Can anyone help? |
#80
|
||||
|
||||
I'm not sure, but I would take a look at exactly what is in that field and see what separates the items and perhaps do a search/replace on the separator with a <br />
|
#81
|
|||
|
|||
Quote:
Anyway here's the url of my site profiles: My Profile - Now what I'm trying to do is display that information in the Rank Information module on the right side under the Mini Stats into a new profile tab. I made the plugin active again so you can see the output under the My Modification tab. Basically want the rank info from the module inside the new tab in a list format. I'll rename the new tab and remove the info from th emodule when I get it working properly. If for some reason you can not see the info I'm talking about on my site here's an example of some information (as listed in the custom field in the admin cp) thats in my custom field that I want displayed in list format. Quote:
Quote:
Hope this helps you help me, lol. Thanks for your time. |
Thread Tools | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|