tjdraper
5/20/2016 - 4:52 AM

EE 2 Template Rendering

// Load the template library
ee()->load->library('template', null, 'TMPL');

// Make sure hidden templates don't prevent us from showing the template
$hiddenChar = ee()->config->item('hidden_template_indicator');
$reverseHiddenChar = $hiddenChar != '.' ? '.' : '_';

ee()->config->set_item('hidden_template_indicator', $reverseHiddenChar);

// Parse the template
ee()->TMPL->fetch_and_parse('group', 'template-name');

// Get the final template
$template = ee()->TMPL->parse_globals(ee()->TMPL->final_template);

// $template should be the rendered template