Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Keep Smarty from converting > to >

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Plugins
View previous topic :: View next topic  
Author Message
coloredbean
Smarty n00b


Joined: 22 Jul 2011
Posts: 1

PostPosted: Fri Jul 22, 2011 7:39 pm    Post subject: Keep Smarty from converting > to > Reply with quote

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
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Sat Jul 23, 2011 12:44 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Plugins All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP