|
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 |
Nilse Smarty n00b
Joined: 15 Sep 2010 Posts: 2
|
Posted: Wed Sep 15, 2010 7:31 pm Post subject: Parsing a string |
|
|
Hi Smarty Community,
i have a string, which contains smarty tags. E.g.: "Hello {$username}"
I have made a new smarty function, which fetches this strings from a database... {getDBEntry id=1}
Is is possible to parse (evaluate) the database entry, BEFORE assigning it to the template?
Something like:
$smarty->parse($string);
$smarty->fetch() is similar, but it only takes templates files...
So, any ideas? |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Wed Sep 15, 2010 8:10 pm Post subject: |
|
|
With Smarty3 you can use the string resource.
$smarty->fetch('string:'.$string); |
|
Back to top |
|
Nilse Smarty n00b
Joined: 15 Sep 2010 Posts: 2
|
Posted: Thu Sep 16, 2010 8:51 am Post subject: |
|
|
Thank you very much...
I did not know that I can use string: with the fetch function...
greetings
Nilse |
|
Back to top |
|
cbj4074 Smarty Regular
Joined: 10 Nov 2011 Posts: 49
|
|
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
|