vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3 Articles (https://vborg.vbsupport.ru/forumdisplay.php?f=187)
-   -   [How-to] Add more tabs to the vB 3.7 profile pages (https://vborg.vbsupport.ru/showthread.php?t=165554)

calorie 12-18-2007 10:00 PM

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

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.

Magnumutz 12-19-2007 09:17 AM

VERY nice calorie... this is really helpful.

Triky 12-19-2007 10:21 AM

This will be helpfull. :)
Thank you!

Lynne 12-24-2007 02:44 AM

Thank you so much for this! It was very helpful.

hfr-Neil 12-26-2007 04:43 PM

Thank you for this tuto ;)

eurofunny 01-01-2008 05:07 PM

Hi, nice Tutorial. Thx

Audentio 01-02-2008 03:31 AM

Excellent, very nice. Thanks for making this for us.

Zaiaku 01-02-2008 11:44 PM

Useful and Helpful Thx!

Berker Unluer 01-02-2008 11:52 PM

Thnx! Excelent!

bdude 01-20-2008 05:33 AM

How do I create a block on the right hand side?


All times are GMT. The time now is 07:08 PM.

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.01759 seconds
  • Memory Usage 1,747KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (5)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)pagenav_pagelinkrel
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete