|
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 |
coloredbean Smarty n00b
Joined: 22 Jul 2011 Posts: 1
|
Posted: Fri Jul 22, 2011 7:39 pm Post subject: Keep Smarty from converting > to > |
|
|
The basic idea:
Let a user use "pseudo variables" like [PHONE] to say "I want my phone number to print out here", and use a smarty modifier to replace the pseudo variable with the real smarty variable.
The Modifier:
function smarty_modifier_replace_defaults($x){
$x=preg_replace('/\[PHONE\]/i','{$default->overview.phone}',$x);
return $x;
}
The problem:
Smarty (at least I think it's smarty) is converting [PHONE] to:
{$default->overview.phone}
Which, of course, doesn't actually print the variable in the smarty template since the syntax no longer makes sense.
I've tried doing return html_entity_decode($x); but no luck. Been spinning in circles for hours on this issue, and I guess I don't know enough to ask google any more clearly. Any help would be greatly appreciated! |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Sat Jul 23, 2011 12:44 am Post subject: |
|
|
The template code generated by the modifier won't get executed anyways. How about this:
Code: | {$foo|replace:'[PHONE]':$default->overview.phone} |
|
|
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
|