Thursday, September 1, 2011

Using $this->set in view doesn't set the var

I have an element in layout that generates some variables I want to use following parts of layout and view. As read in doc (http://book.cakephp.org/view/1086/set), using $this->set('varname', $value) will result in $varname available in the layout, but I'm getting a Undefined variable notice.

debug($this->viewVars) before the var-generating element throws something like:

Array (     [title_for_layout] => Awesome web     [controller_set_var1] => lol     [controller_set_var2] => foo
)

Then, the element is echoed, and debugging $this->viewVars shows:

Array ( [title_for_layout] => Awesome web [controller_set_var1] => lol [controller_set_var1] => lol [element_set_var] => gotcha!
)
But $element_set_var stills undefined.

Is this the normal behavior? Should I take $element_set_var manually from $this->viewVars?

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: