Answer the question
In order to leave comments, you need to log in
Problem migrating from Smarty 2 to Smarty 3?
The question is quite simple, I can not transfer the script to the new version of the template engine.
I used to have this code
function emailtpl_template($tpl_name, &$tpl_source, Smarty $smarty_obj)
{
$tpl_source = $smarty_obj->get_template_vars($tpl_name);
return empty($tpl_source) ? false : true;
}
function emailtpl_timestamp($tpl_name, &$tpl_timestamp, Smarty $smarty_obj)
{
return true;
}
function emailtpl_secure($tpl_name, Smarty $smarty_obj)
{
return true;
}
function emailtpl_trusted($tpl_name, Smarty $smarty_obj)
{
}
$smarty = new Smarty();
$smarty->compile_id = md5($subject . $message . (defined("IN_CRON") ? "cron" : ""));
$smarty->register_resource("emailtpl", array("emailtpl_template", "emailtpl_timestamp", "emailtpl_secure", "emailtpl_trusted"));
$smarty->assign("emailsubject", $subject);
$smarty->assign("emailmessage", $message);
$smarty->assign("plaintext", $message_text);
foreach ($email_merge_fields as $mergefield => $mergevalue) {
$smarty->assign($mergefield, $mergevalue);
}
$subject = $smarty->fetch("emailtpl:emailsubject");
$message = $smarty->fetch("emailtpl:emailmessage");
$message_text = $smarty->fetch("emailtpl:plaintext");
Fatal error: Uncaught --> Smarty: Unable to load template emailtpl 'emailsubject' <-- thrown in W:\domains\test\Smarty\sysplugins\smarty_internal_template.php on line 138
Answer the question
In order to leave comments, you need to log in
In Smarty 3, the registerResource method no longer accepts an array of functions.
It now accepts a successor to the abstract Smarty_Resource class.
www.smarty.net/docs/en/api.register.resource.tpl
$smarty->registerResource("emailtpl", array("emailtpl_template", "emailtpl_timestamp", "emailtpl_secure", "emailtpl_trusted"));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question