From 9ab75d02fb52485f38c788281a3bfd8a06e3026e Mon Sep 17 00:00:00 2001 From: mohrt Date: Thu, 18 Jan 2001 21:09:49 +0000 Subject: [PATCH] added default modifier --- Smarty.addons.php | 9 +++++++++ Smarty.class.php | 3 ++- libs/Smarty.class.php | 3 ++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Smarty.addons.php b/Smarty.addons.php index 0b683ed4..7c53d2da 100644 --- a/Smarty.addons.php +++ b/Smarty.addons.php @@ -127,6 +127,15 @@ function smarty_mod_strip_tags($string, $replace_with_space = true) return strip_tags($string); } +function smarty_mod_default($string,$default="") +{ + if(empty($string)) + return $default; + else + return $string; +} + + /*============================================*\ Custom tag functions \*============================================*/ diff --git a/Smarty.class.php b/Smarty.class.php index e5401301..1b21e404 100644 --- a/Smarty.class.php +++ b/Smarty.class.php @@ -77,7 +77,8 @@ class Smarty 'date_format' => 'smarty_mod_date_format', 'string_format' => 'smarty_mod_string_format', 'replace' => 'smarty_mod_replace', - 'strip_tags' => 'smarty_mod_strip_tags' + 'strip_tags' => 'smarty_mod_strip_tags', + 'default' => 'smarty_mod_default' ); var $global_assign = array( 'SCRIPT_NAME' ); diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index e5401301..1b21e404 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -77,7 +77,8 @@ class Smarty 'date_format' => 'smarty_mod_date_format', 'string_format' => 'smarty_mod_string_format', 'replace' => 'smarty_mod_replace', - 'strip_tags' => 'smarty_mod_strip_tags' + 'strip_tags' => 'smarty_mod_strip_tags', + 'default' => 'smarty_mod_default' ); var $global_assign = array( 'SCRIPT_NAME' );