Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 05-15-2010, 08:14 AM
Wired1's Avatar
Wired1 Wired1 is offline
 
Join Date: Nov 2003
Location: Orlando, FL, USA
Posts: 1,361
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Building a ProfileBlock within a New Tab in Member Profile

Source Articles:
[HOW TO - vB4] Adding a New Tab in Member Profile
[HOW TO - vB4] Rendering templates and registering variables - a short guide
[How-to] Add more tabs to the vB 3.7 profile pages (I know, but some of it still applies when you look at the current 4.03 code)

Note: attached (as well as at the bottom of this post) is my current test project to get more acquainted with the new vB 4.0 code and template system. Yes, I'm fully aware of the junk code that's still in there. No worries, it's commented out!

As an exercise I'm trying to build a new member profile tab with a profile block inside of it. Using the articles above I've managed to create the tab and output basic variables and array data, however I can't output variables from within the ProfileBlock class. I've been looking over the code in class_profileblock.php and member.php for a clue, but I can't figure out what's calling the class itself, so there's a gap in the logic path I'm trying to follow to figure it out!

Any idea how to get the data from block_data['mymodification'] within the ProfileBlock out to the template? I've gotta be missing something basic Yes, there's a couple of lines of test code still in there that probably don't make sense anymore lol

Also as a side question: Do you need to pre-register templates for templates that are within a Product? (don't think so, but can't hurt to ask!)


PHP Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<product productid="extratab" active="1">
    <title><![CDATA[TEST TITLE]]></title>
    <description><![CDATA[TEST DESCRIPTION]]></description>
    <version></version>
    <dependencies>
    </dependencies>
    <codes>
    </codes>
    <templates>
        <template name="my_data_tab" templatetype="template" date="" username="" version=""><![CDATA[
<dd<vb:if condition="$selected_tab == 'test'"> class="selected"</vb:if>><a id="test-tab" href="{vb:raw relpath}#test" onclick="return tabViewPicker(this);">Test</a></dd>
    ]]></template>
        <template name="my_data_data" templatetype="template" date="" username="" version=""><![CDATA[
<div id="view-test" class="<vb:if condition="$selected_tab == 'test'">selected_view_section<vb:else />view_section</vb:if>">
    <div class="blockbody">
        <div class="blockrow">
            <ul class="friends_list floatcontainer">
                my_var = {vb:raw my_var}</br>
                my_array = {vb:raw my_array}</br>
                my_array.key1 = {vb:raw my_array.key1}</br>
                my_array.key2.key21 = {vb:raw my_array.key2.key21}</br>
                </br>
                block_data = {vb:raw block_data}</br>
                block_data.mymodification = {vb:raw block_data.mymodification}</br>
                </br>                
                my_insertvar = {vb:raw my_insertvar}}</br>
                my_insertvar.my_var = {vb:raw my_insertvar.my_var}}</br>
            </ul>
        </div>
    </div>
</div>
        ]]></template>
    </templates>
    <plugins>
        <plugin active="1" executionorder="5">
            <title>Caches Tab</title>
            <hookname>cache_templates</hookname>
            <phpcode><![CDATA[if (THIS_SCRIPT == 'member')
    {
        $cache = array_merge((array)$cache,array(
            'my_data_tab',
            'my_data_data'
        ));
    }

]]></phpcode>
        </plugin>
        <plugin active="1" executionorder="5">
            <title>Test Tab</title>
            <hookname>member_build_blocks_start</hookname>
            <phpcode><![CDATA[

$templater = vB_Template::create('my_data_tab'); 
$templater->register('selected_tab', $selected_tab); 
$templater->register('relpath', $relpath); 
$template_hook['profile_tabs_last'] .= $templater->render();

//$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 = 'my_data_data';

    function confirm_empty_wrap()
    {        return false;     }

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

    function prepare_output($id = '', $options = array())
    {        $this->block_data['mymodification'] = 'Content to show in the tab.';    }
}  


//Do your processing to get your data ready here. 
$my_var = "abc";
$my_array = array(
    'key1' => 'value1',
    'key2' => array( 
        'key21' => 'value21',
        'key22' => 'value22'
        )
    );

//vB_Template::preRegister('my_data_data',array('block_data' => $block_data));

$templater = vB_Template::create('my_data_data'); 

$templater->register('my_var', $my_var);
$templater->register('my_array', $my_array);
$templater->register('block_data', $block_data);

$templater->register('selected_tab', $selected_tab); 
$template_hook['profile_tabs'] .= $templater->render();
$templatevalues['my_insertvar'] = $templater->render();
vB_Template::preRegister('my_data_data', $templatevalues); 

]]></phpcode>
        </plugin>
    </plugins>
    <phrases>
    </phrases>
    <options>
    </options>
    <helptopics>
    </helptopics>
    <cronentries>
    </cronentries>
    <faqentries>
    </faqentries>
</product>
Attached Files
File Type: xml backup - using default code2.xml (3.6 KB, 4 views)
Reply With Quote
 


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 10:35 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.06296 seconds
  • Memory Usage 2,314KB
  • Queries Executed 14 (?)
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
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_attachment
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)showthread_list
  • (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_threadedmode.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_threaded
  • showthread_threaded_construct_link
  • 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
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_attachment
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete