Re: [fw-general] view auto quoting
Hi, Kai Meder wrote: $this->roles is array from db-select json() is kindof shortcut to Zend_Json::encode jsVar('ROLES', json($this->roles)); ?> which results in: var ROLES = "{\"Writer\":{\"role\":\"Writer\"}}"; full helper-source: echo '';echo 'var ' . $name . ' = '; echo json($value); echo ';'; echo ''; echo "\n"; } } the whole thing is quoted twice and it seems to be the view's fault. in the call to $this->jsVar you pass a JSON encoded value, which is a string. In the helper function you encode the $value a second time, hence the escaped string. Removing one off the json() call's will fix it. Kind regards Stefan
Re: [fw-general] view auto quoting
it works when directly outputting in the view-script *without* the helper like: var SNAME = ""; var SID = ""; var ROLES = roles); ?>; yours, kai
Re: [fw-general] view auto quoting
Matthew Weier O'Phinney wrote: Not happening in Zend_View, unless you're registering any filters with the Zend_View object. It may be happening in Zend_Json::encode(), but it should only be occurring if the value is a string. no filters registered at all. double-checked via var_dump($this->getFilters()); How are you calling the helper? simply as: $this->roles is array from db-select json() is kindof shortcut to Zend_Json::encode jsVar('ROLES', json($this->roles)); ?> which results in: var ROLES = "{\"Writer\":{\"role\":\"Writer\"}}"; full helper-source: '; echo 'var ' . $name . ' = '; echo json($value); echo ';'; echo ''; echo "\n"; } } the whole thing is quoted twice and it seems to be the view's fault. i have several ajax-controller which have no views and directly output the json-objects in the actionAction()-methods like so: echo json($db-selected-stuff); it works as expected. in the view-script the output is messed/quoted up and i have *no* idea where to look for this strange behaviour. any ideas? kai
Re: [fw-general] view auto quoting
-- Kai Meder <[EMAIL PROTECTED]> wrote (on Wednesday, 11 July 2007, 10:13 PM +0200): > does the view/view-helper do quoting automatically? No, though there is a facility to do so by registering filters. > view-helper.php > class Zend_View_Helper_JsConstant { > > public function jsConstant($name, $value) { > > echo 'var ' . $name . ' = ' . > Zend_Json::encode($value).';' . "\n"; > } > } > > the value is printed with quotes and the json-quotes are escaped. > any idea who does this quoting and where to turn it off? Not happening in Zend_View, unless you're registering any filters with the Zend_View object. It may be happening in Zend_Json::encode(), but it should only be occurring if the value is a string. How are you calling the helper? simply as: jsConstant() ?> or are you wrapping it in escape(): escape($this->jsConstant()) ?> If the latter (escape), then omit the call to escape(). -- Matthew Weier O'Phinney PHP Developer| [EMAIL PROTECTED] Zend - The PHP Company | http://www.zend.com/
[fw-general] view auto quoting
does the view/view-helper do quoting automatically? view-helper.php echo 'var ' . $name . ' = ' . Zend_Json::encode($value).';' . "\n"; } } the value is printed with quotes and the json-quotes are escaped. any idea who does this quoting and where to turn it off? thanks, kai