PDA

View Full Version : Can I capture a rendered template to a variable?


TalkVirginia
04-01-2011, 05:46 AM
I'd like to either echo it to the screen or write it to a file. If I can do this, I should be able to save it to a variable.

Anyone?

Lynne
04-01-2011, 04:19 PM
Sure.

$newTemplate = vB_Template::create('someTemplate');
$newTemplate->register('variable1', $somearray);
$newTemplate->register('variable2', $variabletwo);
$myvariable = $newTemplate->render();

Then register that variable for use in the template you want to use it in.
vB_Template::preRegister('TEMPLATE', array('myvariable' => $myvariable));