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

Reply
 
Thread Tools Display Modes
  #1  
Old 12-18-2009, 11:00 PM
consolegaming consolegaming is offline
 
Join Date: Jan 2007
Posts: 168
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Loading Template Contents into Plugin

I am in the process of trying to upgrade a plugin of mine for vb4 and I'm trying to reproduce the effect of the following code:

PHP Code:
eval('$activeonlineusers[\'team\'] .= ", ' fetch_template('forumhome_loggedinuser') . '";'); 

I have tried two different things:
PHP Code:
$activeonlineusers['team'] .= ", "$vbulletin->templatecache["forumhome_loggedinuser"]; 

and:
PHP Code:
$activeonlineusers['team'] .= ", ".$templater->render();
$templater vB_Template::create('forumhome_loggedinuser'); 

The latter just shows the commas and the former shows something resembling the below:
Code:
# Hello $final_rendered = ' ' . vB_Template_Runtime::fetchStylevar("dirmark") . ' ' . $loggedin['musername'] . '' . $loggedin['invisiblemark'] . '' . $loggedin['buddymark'] . '
# ';Hello $final_rendered = ' ' . vB_Template_Runtime::fetchStylevar("dirmark") . ' ' . $loggedin['musername'] . '' . $loggedin['invisiblemark'] . '' . $loggedin['buddymark'] . '
';
Hello = what I put in, instead of the comma's to make sure the seperator was being added.

I'm probably just missing something really obvious but sometimes you get to the point where you just can't see the answer lol. It's not an issue with registering variables because it does output (another plugin uses this array to replace the one that is outputted).
Reply With Quote
  #2  
Old 12-19-2009, 01:32 AM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Cellarius wrote a really good article that you may be interested in - [vB4] Rendering templates and registering variables - a short guide
Reply With Quote
  #3  
Old 12-19-2009, 12:57 PM
consolegaming consolegaming is offline
 
Join Date: Jan 2007
Posts: 168
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I've read that thread a few times (before posting this) but I'm not sure it actually helps my situation.

I've just tried registering the variable as a seperate variable (which isn't what I want to do - I want to replace the one that's already getting displayed - hence no template edits) and that still didn't work.

It seems that the output of:

PHP Code:
$templater vB_Template::create('forumhome_loggedinuser');

$activeonlineusers['team'] .= "Hello".$templater->render(); 
is only showing the Hello's. the output of the $templater->render() appears to be blank. And this plugin is assigned to the forumhome_loggedinuser hook. I don't see why this template would appear blank.

As I said I do register the variables (in another plugin i.e. once the variable has finished being set). Though in the final thing I just want to replace the existing $activeusers variable without having to make a template change.
Reply With Quote
  #4  
Old 12-19-2009, 03:19 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Well, if you look at the template forumhome_loggedinuser, it needs the variable $loggedin. You have done nothing to register that variable for use in the template.

PHP Code:
            $templater vB_Template::create('forumhome_loggedinuser');
                
$templater->register('loggedin'$loggedin);
            
$activeonlineusers['team'] .= "Hello".$templater->render(); 
Reply With Quote
  #5  
Old 12-19-2009, 03:27 PM
consolegaming consolegaming is offline
 
Join Date: Jan 2007
Posts: 168
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ah, I think that's the breakthrough I needed. It seems to have worked from the quick test I did.

I had made the assumption I didn't need to register any existing variables because I thought they would already be registered (otherwise they wouldn't work in the first place). Now I know that I'll need to re-register them in that sort of situation.
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 01:15 AM.


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.05908 seconds
  • Memory Usage 2,206KB
  • Queries Executed 11 (?)
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)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (5)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (5)post_thanks_box
  • (5)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (5)post_thanks_postbit_info
  • (5)postbit
  • (5)postbit_onlinestatus
  • (5)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
  • 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_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete