|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
mmerlone Smarty Rookie
Joined: 03 Jan 2007 Posts: 5
|
Posted: Wed Jan 03, 2007 4:54 pm Post subject: Compile vars after register_function |
|
|
Hello all!
I have extended the smarty class so I can configure it and etc. There I have a function like this:
Code: | $this->register_function('tr', 'translate'); |
which returns the translated string from a block like this:
Code: | {tr id="12" value="Original text here"} |
If the string whose id=12 is not found so it returns the value parameter. Everything works fine as expected, except for one detail: I cannot have smarty vars inside the value, like:
Code: | {tr id="14" value="There are $qtd monkeys at the zoo."} |
The test I am doing:
PHP:
Code: | $sm->assign('CFG_USUARIO_DB_USERNAME', 'username');
$sm->assign('u', array('username' => 'Jhon'));
$sm->assign('foo', 'foo foo foo'); |
Template:
Code: |
<p>{!tr id="20" value="Texto teste para teste $foo de tradução com variável: $u.$CFG_USUARIO_DB_USERNAME"}</p>
<p>Texto teste para teste {$foo} de tradução com variável: {$u.$CFG_USUARIO_DB_USERNAME}</p>
|
And the resulting html output:
Code: |
Test text to test $foo translation with a var: $u.$CFG_USUARIO_DB_USERNAME
Texto teste para teste foo foo foo de tradução com variável: Jhon
|
I have tried:
Code: | {tr id="20" value="Texto teste para teste {!$foo} de tradução com variável: {!$u.$CFG_USUARIO_DB_USERNAME}"} |
but obviously it screams about syntax error.
Can you help me find a trick to compile those vars AFTER the execution of the 'tr' function?
Thanks for any help, hint, idea.
Best regards, _________________ Marcio Merlone |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|