Re: problem passing variables
| From: | Andrei Zmievski | Date: | Thu, 10 May 2001 13:12:14 +0000 |
| Subject: | Re: problem passing variables | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-724@lists.php.net to get a copy of this message | ||
Your custom functions receive only 2 arguments: the associative array of
parameters, and the smarty object. Try this:
function smarty_func_translate($params, &$smarty)
{
extract($params);
// use your parameters now..
}
On Thu, 10 May 2001, Tomas Sanchez Romani wrote:
> Hi, I'm having trouble with passing variables to a custom function I'm
> trying to do.
>
> ---the function:
>
> /*============================================*\
> Function: smarty_func_translate
> Purpose: translate the string ($strId) with STPhp
> \*============================================*/
>
> function smarty_func_translate($strId, $toStr, $locLang, $locPath, $locMech)
> {
> include("../stphp/code/st/st.php");
> global $LocalePath, $LocaleMechanism;
> $LocalePath = $locPath;
> $LocaleMechanism = $locMech;
> eval (ST ($strId, "\$toStr", $locLang));
> echo $toStr;
> }
>
> ---the call from within the tamplate:
>
> {translate locLang=$locLang locPath=$locPath locMech=$locMech strId=$strId
> toStr=$toStr}
>
> ---the assigning from the script:
>
> $smarty->assign("locLang", $locLang);
> $smarty->assign("locMech", $locMech);
> $smarty->assign("toStr", $toStr);
> $smarty->assign("strId", $strId);
> $smarty->assign("locPath", $locPath);
>
> ---the result:
>
> Warning: Missing argument 3 for smarty_func_translate()
> in Smarty.addons.php on line 45
>
> Warning: Missing argument 4 for smarty_func_translate()
> in Smarty.addons.php on line 45
>
> Warning: Missing argument 5 for smarty_func_translate()
> in Smarty.addons.php on line 45
>
> ---the question:
>
> what's wrong?
>
> please help, a&l, tomas
>
>
> ---
> You are currently subscribed to smarty as: andrei@ispi.net
> To unsubscribe send a blank email to $subst('Email.Unsub')
> Visit Smarty's homepage at
> http://www.phpinsider.com/php/code/Smarty/
-Andrei
When we eliminate the impossible, whatever remains,
however improbable, must be true. -- Sherlock Holmes