View previous topic :: View next topic |
Author |
Message |
comicway Smarty Rookie
Joined: 14 Aug 2006 Posts: 8
|
Posted: Tue Aug 15, 2006 7:20 am Post subject: Assigned variables not compiled |
|
|
Hi all
I've got a question:
I would like to do this:
$smarty->assign("mavariable","test");
$smarty->assign("variable_test","{$mavariable}");
And i would like that {$mavariable} is replace by test
i've tried with prefilter, modificator,... but noway.
The problem is that i want to receve a row in my db like :
This is my text [name], ...
i will change de [name] to {$name_var} but this var must be executed (replace by smarty)
How i can do that?
Thanks a lot. |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Tue Aug 15, 2006 7:45 am Post subject: |
|
|
why do you all ask the same questions?
ask new questions or read the other posts. |
|
Back to top |
|
comicway Smarty Rookie
Joined: 14 Aug 2006 Posts: 8
|
Posted: Tue Aug 15, 2006 7:54 am Post subject: |
|
|
I've read yesterday a lot of topic and try to search with the words (assigned var,...)
but i've didn't find.
Can you help me? |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
|
Back to top |
|
comicway Smarty Rookie
Joined: 14 Aug 2006 Posts: 8
|
Posted: Tue Aug 15, 2006 8:33 am Post subject: |
|
|
Ok i've reed that ressource is great but in my code i've got this:
$smarty->assign("info",$info);
// info: Hello {$name}{if $mr eq '1'}Connect{if}
$smarty->display('test.tpl');
and in my test.tpl:
<html>
<body>
{$info}
</body>
</html>
I didn't want to get a template from DB or other i've just want to like a prefilter that php replace {$info} by Hello {$name}{if $mr eq '1'}Connect{if}
and smarty execute this.
I think it is not possible with resources or i've didn't understant right
Thanks for your help
cris |
|
Back to top |
|
shannera Administrator
Joined: 13 Feb 2006 Posts: 802 Location: Edertal, Germany
|
|
Back to top |
|
comicway Smarty Rookie
Joined: 14 Aug 2006 Posts: 8
|
Posted: Tue Aug 15, 2006 9:41 am Post subject: |
|
|
I've tried this prefilter:
Code: |
$smarty->assign("test","[bb]test[/bb]");
function change_code($tpl_source, &$smarty)
{
return preg_replace("/(?<!\\\\)\[bb(?::\w+)?\](.*?)\[\/bb(?::\w+)?\]/si",'{$info.id}',$tpl_source);
}
$smarty->register_prefilter('change_code'); |
$smarty->display('info.tpl');
but the assign is do after the prefilter and theres no change i've got this:
[bb]test[/bb] and no 15 (the id of info) |
|
Back to top |
|
comicway Smarty Rookie
Joined: 14 Aug 2006 Posts: 8
|
Posted: Wed Aug 16, 2006 11:41 am Post subject: |
|
|
Nobody? |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
|
Back to top |
|
comicway Smarty Rookie
Joined: 14 Aug 2006 Posts: 8
|
Posted: Wed Aug 16, 2006 1:54 pm Post subject: |
|
|
No, i'will try it smell good... |
|
Back to top |
|
|