Hello all,
I’ve got two custom plugins being called on the same page, both of which use the template library to parse a template (as outlined by Derek Jones here). I’m using it like so:
Plugin code (effectively the same in both plugins):
$view_data = array('some', 'array');
$this->EE->load->library('Template', NULL, 'TMPL');
$this->EE->TMPL->fetch_and_parse('shared', '_template_name_here');
$content = $this->EE->TMPL->parse_globals($this->EE->TMPL->final_template);
$this->EE->TMPL->parse_variables_row($content, $view_data);Template
{exp:plugin_one}
{exp:plugin_two}Plugin one renders with no problems, but when it gets to the line
$this->EE->load->library('Template', NULL, 'TMPL');in plugin two, things stop parsing. I assume it’s something to do with the library being loaded twice?
Any help very gratefully received!
Moved to Development and Programming by Moderator
James
You could try instantiating the library yourself in the local scope:
$view_data = array('some', 'array');
$TMPL = new EE_Template;
$TMPL->fetch_and_parse('shared', '_template_name_here');
$content = $TMPL->parse_globals($TMPL->final_template);
$TMPL->parse_variables_row($content, $view_data);Hi all,
I’m trying to do a very similar thing to James, and having been using Rob’s solution to do it.
However - if I try and parse a template with an embed tag in it (i.e. {embed="group/template}) it just outputs a message that says ‘You have caused a template loop due to improperly nested sub-templates’.
Also… if I have an {exp:channel:entries} tag pair in there, nothing is output from within that pair. Truning on error reporting shows me the following error:
A PHP Error was encountered
Severity: Notice
Message: Undefined property: EE::$TMPL
Filename: channel/mod.channel.php
Line Number: 221 Fatal error: Call to a member function fetch_param() on a non-object in /Users/markp/Dropbox/Mark/Medium/Clients/DOGWF_Dogwoof_Films/_sites/goodwithfilm.com/httpdocs/admin/expressionengine/modules/channel/mod.channel.php on line 221
Anyone have any ideas what may be causing this? Any help would be greatly appreciated!!
Cheers,
Mark
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.