wow! these are big help. Now I have two very good options, and help me to save time
I think, like Calguy says, in most of cases, my best solution should be to use lib/classes, something like this:
Code: Select all
$config ...;
$filename = ...;
require_once($filename);
// UDT:test, p.e. using Classes.php from /lib
$me = new MyClass();
$me->displayVar('Something here... from UDT');
Amazing!... simple and clear.
However, doing a couple of test using modules and tags inside of UDTs like Rolf's help is confortable. I did this:
Code: Select all
// plugins/function.test.php
function smarty_function_test($params, &$template)
{
if(isset($params) && count($params) > 0){
if(isset($params['param2'])){
$params['param2'] = do_some($params['param2']);
}
$listparams = ' + Yes params ('.print_r($params).')';
}else{
$listparams = '';
}
$hi = "Hello World!".$listparams;
return $hi;
}
function do_some($str){
$go = "running function do_some('$str')";
return $go;
}
And then the UDT:
$txt = "{test}";
// calling the plugin
$smarty->display('eval:'.$txt);
$heredoc =
$smarty->fetch('eval:{test param1=1 param2="my string" param3=array(1,2,"c")}');
echo "...Now I'm in the UDT, its \$heredoc = $heredoc";
I hope the practice or sintax must be the appropiate, I mean, been into the good practices, I don't know if call a smarty->display|fetch instruction is correct
Men, many thanks for the tips