Warnings even when using "default" modifier

From: Date: Fri, 11 Oct 2002 16:59:49 +0000
Subject: Warnings even when using "default" modifier
Groups: php.smarty.dev 
Request: Send a blank email to php-smarty-dev+get-293@lists.php.net to get a copy of this message
Hi, given the following (pseudo-) code <?php .... $a = array ("a"=>"aa", "b"=>"bb"); $smarty->assign("a"=>$a); $smarty->display("my.tpl"); ?> with my.tpl containing <html> <body> a={$a.a|default:"(no content)"}<br> b={$a.b|default:"(no content)"}<br> c={$a.c|default:"(no content)"}<br> </body> </html> I'm getting a warning "Undefined index: c in /path/to/compiled/template.php". This is because Smarty_Compiler and plugins/modifier.default.php can not handle undeclared variables as documented. To get documented behaviour, I did these small modifications (semi-udiff): In Smarty_Compiler.class.php:1246 - $output = "\$this->_run_mod_handler('$modifier_name', $map_array, $output$modifier_args)"; + $output = "\$this->_run_mod_handler('$modifier_name', $map_array, "."&"."$output$modifier_args)"; And in plugins/modifier.default.php:13 - if (empty($string)) + if (!isset($string) || empty($string)) Just wanted to let u know... Thomas

« previous php.smarty.dev (#293) next »