format variable if it has been set

From: Date: Thu, 07 Mar 2002 10:37:15 +0000
Subject: format variable if it has been set
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-2962@lists.php.net to get a copy of this message
Hi, what is the most convenient and the shortest way to format a variable (like using string_format variable modifier) if and only if the correspondig variable has been set/assigned? I know that the following code can do the job: {if isset($variable)} {$variable|string_format:'the value of variable: %s'} {/if} when $variable is set to "Hello" it will display: the value of variable: Hello but if it's not set, then it results a blank page. I come up with a new modifier to reduce the complexity of my templates, so I'm just wondering if it can be achieved by any other way ,for example, combining built-in modifiers somehow? {$variable|ifformat:'the value of variable: %s'} Papp Gyozo - pgerzson@freestart.hu

« previous php.smarty.general (#2962) next »