Re: [SMARTY] default modifiers vs. foreach & if

From: Date: Mon, 14 May 2007 11:08:13 +0000
Subject: Re: [SMARTY] default modifiers vs. foreach & if
References: 1  Groups: php.smarty.dev php.smarty.general 
Request: Send a blank email to php-smarty-general+get-13708@lists.php.net to get a copy of this message
Hey. I am not able to reproduce this. Could you please submit a working sample? And yes, this should go to the dev list if you think its a bug. Bye. Artemy Tregoubenko schrieb: > Hello everyone. > > I just tried to use this nice feature of smarty: > http://smarty.php.net/manual/en/variable.default.modifiers.php > I think that auto-escaping of all values when outputting them is a great > idea, so i set $this->default_modifiers = array('escape:"html"'); > > It worked nice until I tried to use foreach to iterate over array of > arrays. I got lots of messages like this: > Warning: htmlspecialchars() expects parameter 1 to be string, array > given... > > The same warnings were displayed when using "{if $array}". > > I looked into compiled templates and found that smarty applies default > modifiers to all parameters of foreach, including > "from=$array_of_arrays", and this generates warning. > > Hiding warnings is a bad practice, so I'm looking for another solution > for this problem. By now I hacked _compile_foreach_start and > _compile_if_tag so that default_modifiers are toggled off in the > beginning and restored at the end of methods. I understand this is only > partial solution. > > Can anyone, having deeper knowledge of smarty compiler, suggest better > way to fix this? > Or should I write about my problem to dev list? >

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