diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/template.class.php | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/include/template.class.php b/include/template.class.php index d0387b138..056d54102 100644 --- a/include/template.class.php +++ b/include/template.class.php @@ -121,6 +121,7 @@ class Template $this->smarty->registerPlugin('modifiercompiler', 'translate', array('Template', 'modcompiler_translate') ); $this->smarty->registerPlugin('modifiercompiler', 'translate_dec', array('Template', 'modcompiler_translate_dec') ); $this->smarty->registerPlugin('modifier', 'explode', array('Template', 'mod_explode') ); + $this->smarty->registerPlugin('modifier', 'ternary', array('Template', 'mod_ternary') ); $this->smarty->registerPlugin('modifier', 'get_extent', array($this, 'get_extent') ); $this->smarty->registerPlugin('block', 'html_head', array($this, 'block_html_head') ); $this->smarty->registerPlugin('block', 'html_style', array($this, 'block_html_style') ); @@ -665,7 +666,7 @@ class Template /** * "explode" variable modifier. * Usage : - * - {assign var=valueExploded value=$value|@explode:','} + * - {assign var=valueExploded value=$value|explode:','} * * @param string $text * @param string $delimiter @@ -675,6 +676,21 @@ class Template { return explode($delimiter, $text); } + + /** + * ternary variable modifier. + * Usage : + * - {$variable|ternary:'yes':'no'} + * + * @param mixed $param + * @param mixed $true + * @param mixed $false + * @return mixed + */ + static function mod_ternary($param, $true, $false) + { + return $param ? $true : $false; + } /** * The "html_head" block allows to add content just before |