We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
With Smarty 3.1.21 the following used to work:
require 'smarty-3.1.21/libs/Smarty.class.php'; $s = new Smarty(); $s->registerPlugin('function', 'myTestFunction', 'myTestFunction'); $s->display('test.tpl'); function myTestFunction ($params, $smarty) { $smarty->assign('value', $params['testvalue']); return $smarty->fetch('eval:' . $params['testhtml']); }
Contents of test.tpl:
test value: {myTestFunction testvalue='5' testhtml='"{$value}"'}
The output would be as follows:
test value: "5"
However, the same code with 3.1.29 loaded gives me the following result:
test value: ""
Is this expected behaviour, is there something I am supposed to be doing differently since some version after 3.1.21? Or is this a bug?
The text was updated successfully, but these errors were encountered:
- bugfix if fetch('foo.tpl') is called on a template object the $pare…
a687a12
…nt parameter should default to the calling template object #152
The root cause is that in Smarty 3 the 2nd parameter of plugins is the calling template object but not the Smarty object. Correctly it should be
function myTestFunction ($params, $template) { $template->smarty->assign('value', $params['testvalue']); return $template->smarty->fetch('eval:' . $params['testhtml']); }
There is a fallback that you can call must methods also on a template object and some link got broken in your example.
The fix is now in the master branch and will late be included in 3.1.30
Sorry, something went wrong.
Great, thanks!
No branches or pull requests
With Smarty 3.1.21 the following used to work:
Contents of test.tpl:
test value: {myTestFunction testvalue='5' testhtml='"{$value}"'}
The output would be as follows:
However, the same code with 3.1.29 loaded gives me the following result:
Is this expected behaviour, is there something I am supposed to be doing differently since some version after 3.1.21? Or is this a bug?
The text was updated successfully, but these errors were encountered: