vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=251)
-   -   Register existing template (https://vborg.vbsupport.ru/showthread.php?t=274089)

Alteczen 11-16-2011 12:00 AM

Register existing template
 
I've seen multiple example on how to register a custom template in an existing template but not the other way around. If I create a custom template called 'mytemplate' can anyone provide me a working example to register a stock template so that it can render inside my custom template?

I'm trying to render the memberinfo_block_friends template inside my custom template. I've tried numerous hooks and have been beating my head against the desk for the past 3 hours.

Thanks in advance.

kh99 11-16-2011 12:06 AM

There shouldn't be any difference between using a "stock" template and a custom template, although no matter what template you use, you need to register all the variables it uses before it's rendered (as well as calculate the values for them). How are you using your custom template? In a plugin (and if so, which hook), or in a custom page?

Alteczen 11-16-2011 12:13 AM

I'm using the "add a tab" mod as a plugin from here. It adds an additional tab to the member profile area.

https://vborg.vbsupport.ru/showthread.php?t=265971

Using that I have a custom template called 'custom_profile_tab_dashboard'. I want to render the memberinfo_block_friends template inside this custom template.

I've tried multiple variations with no luck on the hook member_complete. I'm basically trying to move the sidebar blocks on the member profile page into this custom template. I've tried modifying the above mod to include:
Code:

$templater->register('blocklist',  $blocklist);
$templater->register('memberinfo',  $memberinfo);
$templater->register('prepared',  $prepared);
$templater->register('userinfo',  $userinfo);
$templater->register('member',  $member);

I couldn't get that to do anything though... Any advise on direction would be phenominal.

--------------- Added [DATE]1321406167[/DATE] at [TIME]1321406167[/TIME] ---------------

I'm hoping to use the existing templates to render the content - just in a different place. I'm hoping I wouldn't have to build a query to get friends based on a userid - pass them into a variable - just to reuse that template..???

kh99 11-16-2011 12:33 AM

Try doing something like this: from that article on adding a tab, at the bottom of the plugin code is this:

Code:

$templater = vB_Template::create('custom_profile_tab_test');
$templater->register('selected_tab', $selected_tab);
$templater->register('test_tab_content', $test_tab_content);
$template_hook['profile_tabs'] .= $templater->render();


so I assume you have something similar for your custom template. Try adding (before the render() line):
Code:

$templater->register('friends', $blocks['friends']);

and then in your custom template:
Code:

{vb:raw friends}

BTW, this is kind of a guess from looking at the code in member.php - I haven't tried this at all.


All times are GMT. The time now is 10:23 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.02218 seconds
  • Memory Usage 1,719KB
  • 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
  • (4)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete