one of my function fails with 2.6.4 or 2.6.5
| From: | Olivier Hericord | Date: | Tue, 14 Sep 2004 12:18:59 +0000 |
| Subject: | one of my function fails with 2.6.4 or 2.6.5 | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-11807@lists.php.net to get a copy of this message | ||
hi,
i've got a problem:
one of my smarty function fails to work with smarty 2.6.4 and 2.6.5....i need a little help:
to achieve translations i use prefilters...like a lot of smarty users....
but when i want to include a dynamic translated string a use 2 custom functions.
1) the first can translate dynamicaly something coming from a database
i use it like that:
{translate VERBOSE=$SPECIALITE[row]}
translate connect to a database, fetch the desired row with the verbose parameter and then takes the 'fr' or the 'en' field to achieve translation
ex:
DATABASE FIELDS: verbose fr en
salut bonjour hello
nom nom name
....... ....... .......
2)but sometimes i want the 'fr' or the 'en' field to contain something dynamic
like verbose: "complete_hello_how_are_you"
fr: "Bonjour {if $PERSON_SEXE == 0}{traducteur VERBOSE="madame"}{else}{traducteur VERBOSE="monsieur"}{/if} {$PERSON_NOM}, comment allez vous?"
en: "Hi {if $PERSON_SEXE == 0}{traducteur VERBOSE="madame"}{else}{traducteur VERBOSE="monsieur"}{/if} {$PERSON_NOM}, how are you?"
and then writing in my template :
{translate2 VERBOSE="complete_hello_how_are_you"}
here is the code for translate2:
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* Type: function * Name: translate2* Purpose: translate * ------------------------------------------------------------- */ function smarty_function_translate2($params, &$this) {
extract($params);$trad = new translate_from_db; $this->_compile_source("evaluated template", $trad->traducteur($VERBOSE), $source); // $this->_compile_template("evaluated template", $trad->traducteur($VERBOSE), $source); eval('?>' . $source); } ?> since the 2.6.4 update that function doesn't work anymore....it just output "translate2" on screen... HELLLLLLPPPPP!!!!! thanks