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

stripslashes modifier

 
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
ThermoDust
Smarty Regular


Joined: 10 Sep 2003
Posts: 38

PostPosted: Wed Sep 24, 2003 7:27 pm    Post subject: stripslashes modifier Reply with quote

I found that I needed this plugin or option while using smarty. I didn't see it in the Wiki Plugin area so here it is. This plugin will strip slahes that were added using addslashes(). I know its very simple but some may need it Smile.

[php]
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* Type: modifier
* Name: stripslashes
* Version: 0.4
* Date: Sep 24 2003
* Author:
* Purpose: Un-quote string quoted with addslashes()
* Example: {$text|stripslashes}
* -------------------------------------------------------------
*/
function smarty_modifier_stripslashes($string)
{
return stripslashes($string);
}
?>[/php]


Last edited by ThermoDust on Mon May 09, 2016 3:30 am; edited 1 time in total
Back to top
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Wed Sep 24, 2003 7:44 pm    Post subject: Reply with quote

Hi ThermoDust.

You actually don't need a wrapper function for this as {$somevar|stripslashes} should work as-is. Here is the relevant section from the manual:

Quote:
Modifiers can be autoloaded from your $plugins_dir (also see: Naming Conventions) or can be registered explicitely (see: register_modifier). Additionally all php-functions can be used as modifiers implicitely. (The @count-example above actually uses php's count-function and not a smarty-modifier). Using php-functions as modifiers has two little pitfalls: First: Sometimes the order of the function-parameters is not the desirable one ({"%2.f"|sprintf:$float} actually works, but asks for the more intuitive {For example: $float|string_format:"%2.f"} that is provided by the Smarty distribution). Second: with $security turned on all php-functions that are to be used as modifiers have to be declared trusted in the $security_settings['MODIFIER_FUNCS']-array.
Back to top
View user's profile Send private message
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