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?
ExpressionEngine implements Markdown Extra and BBCode. Please see the Markdown Extra docs and the BBCode Wikipedia article for a full reference.
**bold**
, __bold__
, *italics*
, _italics_
, ~strike/del~
, `code()`
bold, italics, strike/del, code()
Link: [link title](https://example.com)
Image: ![alt text](https://example.com/image.jpg)
[blockquote]...[/blockquote]
, [quote]...[/quote]
, and Markdown style:
> Some quoted text. > > This is all one quote.
[code]...[/code]
, and you can also specify the language for syntax highlighting, [code=php]...[/code]
GitHub flavored Markdown code fences are also supported:
``` public function decoderRing($str) { return str_rot13($str); } ```