Yeah you can't use set() to magically push a variable into the layout scope from an element. That's simply impossible in PHP. If you have an element in your layout that uses View::set() you should either get it from $this->viewVars or use $this->getVar(). To access it later in the layout.
-Mark On Sep 10, 3:37 am, WebbedIT <[email protected]> wrote: > Yip, the api does state "Allows a template or element to set a > variable that will be available in a layout or other element", but > maybe this is when the element is being called from the view not the > layout? > > People are not really supposed to read your layout though, that is set > and should rarely be changed. Plus it's a lot cleaner to only be > echoing $content_for_layout, $menu_for_layout etc. than it is to be > calling all view data from the layout. > > However, I am not experienced enough with MVC to give a compelling > argument against it, I just know when something rubs against Cake's > conventions then it;s normally not a good idea. > > HTH, Paul. > > On Sep 9, 9:18 pm, Xoubaman <[email protected]> wrote: > > > > > > > > >http://api13.cakephp.org/class/view#method-Viewsethttp://book.cakephp... > > > Someone of the core team answered that Var::set could be used to solve a > > similar issue in a post I here found when searching to my question. Don't > > remember the search subject now :( > > > I mean cleaner in the sense of it's more readable one layout with some echo > > $var that another one with some echo $this->element(name, params stuff), > > almost in the application I'm developing. Maybe it's not the most elegant > > way, but, if we should not set vars in the views, why is still a method to > > do it? -- 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 [email protected] For more options, visit this group at http://groups.google.com/group/cake-php
