Bug #23429 See Comments

Template class parse method fails in custom module control panel

Version: 4.0.1 Reporter: anthony.pinskey

I wanted to use the Template class to manually parse my templates and store them in an index database table.

I have the method being triggerd as a custom form action in the backend of my module’s control panel, so the method is not being called directly from the template.

mcp.mymodule.php

function index_template() 
{
/* Template code to parse */
$template_code = '{variable_to_parse}';
/* Load the Template class */
ee()->load->library('template');
/* Parse the template code */a
ee()->template->parse($template_code);
echo $template_code
}

Here are the contents of the template

<h2>Product Listing</h2>
{exp:channel:entries channel="products"}
  {title}
  {product_price}
{/exp:channel:entries}

It doesn’t parse it and just returns a random encoded string back with the template code’s original values

{!-- ra:000000004613792b000000010e895878 --}{variable_to_parse}

If I call this exact same method from a function on my module like {exp:mymodule:index_template} it will work. But only when it’s being called directly from a template/page load.

Is there no way to parse the templates manually even when the method is being passed the template string directly?

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases