Replies: 5 comments 6 replies
-
You could continue to use Or you can create an Extension class like this: <?php
use Smarty\Extension\Base;
class MyExtension extends Base {
public function getModifierCallback(string $modifierName) {
switch ($modifierName) {
case 'getPlantes': return [$this, 'smarty_function_getPlantes'];
}
return null;
}
public function smarty_function_getPlantes($iParams, $iTemplate) {
// ....
}
} |
Beta Was this translation helpful? Give feedback.
-
I have too many plugins and modifiers to do this extension one by one. Note: how to remove this deprecated message? Thanks wisskid |
Beta Was this translation helpful? Give feedback.
-
OK I spend my weekend to transfer all my functions and modifiers in 2 extensions... (as you explain). But impossible to have something working. I have always this fatal error
This kind of message doesn't help to understand what's wrong. How to find the problem? How to debug? |
Beta Was this translation helpful? Give feedback.
-
Hereafter my code, certainly something I don't understand Extension for functions
Extension for modifiers
How I add those extensions in smarty
|
Beta Was this translation helpful? Give feedback.
-
If I replace the extension with a loop for my functions with
and for my modifiers with
It works!!!! The list of modifiers and functions is the same. Is there a way to have more traces to understand this error "Call to a member function handle() on null...."? My templates are complex with inheritances and a lots of modifiers and functions. I cannot really simplify them to understand the problem |
Beta Was this translation helpful? Give feedback.
-
Sorry but I don't really understand what to do with my plugins and modifiers to have them ok in v5?
I have more than 50 plugins and same for modifiers, how can I register them all automatically as before?
In a folder /plugins I have for example the file function.getPlantes.php
Now I initialize smarty with
$smarty->addPluginsDir(SMARTY.'/plugins');
And now I understand that I have to set all the plugins one by one, right?
$smarty->registerPlugin(Smarty\Smarty::PLUGIN_FUNCTION, 'getPlante', 'smarty_function_getPlante');
Does smarty loads all the functions in the /plugins folder?
The file name is function.getPlantes.php and the function name is smarty_function_getPlante, is that ok?
I don't really understand how to do my migration easily, the doc doesn't help very well.
Thanks for your help
Beta Was this translation helpful? Give feedback.
All reactions