That will work, but that's really not what $session is designed for;
you're not trying to store persistent data. I've used plenty of hacks
like that myself, but I generally try to avoid them because it makes
the code much less intuitive to others. And if there's a "correct" way
of doing the same thing for the same amount of work, you may as well
do it the standard way.

AFAIK, Controller::set() and View::set() both set variables in View::
$viewVars and Controller::$viewVars (which gets passed to View::
$viewVars). So just use the set() function like you would normally, or
you can manipulate the $viewVars property directly. There may be
another way of doing it, but that's how I did it on a previous site
when I needed to generate embedded javascript from within a helper.

And FYI, the scripts that are going to be included through
$scripts_for_layout are stored in View::__scripts.

On Apr 29, 12:01 am, Ed Propsner <crotchf...@gmail.com> wrote:
> 8-)
>
>
>
> On Thu, Apr 29, 2010 at 3:00 AM, Andrei Mita <andrei.m...@gmail.com> wrote:
> > Forget about what? :))
>
> > On Thu, Apr 29, 2010 at 9:49 AM, Ed Propsner <crotchf...@gmail.com> wrote:
>
> >> LOL, I obviously need to call it quits for the day ... talk about
> >> over-thinking that one!  It honestly didn't even dawn on me to try session
> >> vars ... lol.
>
> >> What do you say we both just walk away and forget this ever happened? 8-)
>
> >> - Ed
>
> >> On Thu, Apr 29, 2010 at 2:33 AM, Andrei Mita <andrei.m...@gmail.com>wrote:
>
> >>> Maybe I didn't get it right, but if you need a var globally available
> >>> (controllers, views, layouts) you could use $session. Easy to set and read
> >>> everywhere.
>
> >>> Andrei
>
> >>> On Thu, Apr 29, 2010 at 8:47 AM, Ed Propsner <crotchf...@gmail.com>wrote:
>
> >>>> Could someone help get me pointed in the right direction?
>
> >>>> I want to be able to set a variable in any one of my controllers/actions
> >>>> that is accessible
> >>>> by the default.ctp just like you would do for $page_title /
> >>>> $title_for_layout.
>
> >>>> I want to use it mainly for javascript so I would like to set the
> >>>> variable in the controller/action
> >>>> and the appropriate script will execute in the default.ctp when the view
> >>>> is rendered, either that
> >>>> or I could store the script in an element and have the appropriate
> >>>> element rendered in the default ???
>
> >>>> Anywho, I've been digging through the book and I'm not quite sure where
> >>>> I should be looking.
> >>>> Components? Bootstrapping? Heck if I  know 8-)
>
> >>>> Thanks,
>
> >>>> - Ed
>
> >>>>  Check out the new CakePHP Questions sitehttp://cakeqs.organd help
> >>>> others with their CakePHP related questions.
>
> >>>> You received this message because you are subscribed to the Google
> >>>> Groups "CakePHP" group.
> >>>> To post to this group, send email to cake-php@googlegroups.com
> >>>> To unsubscribe from this group, send email to
> >>>> cake-php+unsubscr...@googlegroups.com<cake-php%2bunsubscr...@googlegroups.com>For
> >>>>  more options, visit this group at
> >>>>http://groups.google.com/group/cake-php?hl=en
>
> >>>  Check out the new CakePHP Questions sitehttp://cakeqs.organd help
> >>> others with their CakePHP related questions.
>
> >>> You received this message because you are subscribed to the Google Groups
> >>> "CakePHP" group.
> >>> To post to this group, send email to cake-php@googlegroups.com
> >>> To unsubscribe from this group, send email to
> >>> cake-php+unsubscr...@googlegroups.com<cake-php%2bunsubscr...@googlegroups.com>For
> >>>  more options, visit this group at
> >>>http://groups.google.com/group/cake-php?hl=en
>
> >>  Check out the new CakePHP Questions sitehttp://cakeqs.organd help
> >> others with their CakePHP related questions.
>
> >> You received this message because you are subscribed to the Google Groups
> >> "CakePHP" group.
> >> To post to this group, send email to cake-php@googlegroups.com
> >> To unsubscribe from this group, send email to
> >> cake-php+unsubscr...@googlegroups.com<cake-php%2bunsubscr...@googlegroups.com>For
> >>  more options, visit this group at
> >>http://groups.google.com/group/cake-php?hl=en
>
> >  Check out the new CakePHP Questions sitehttp://cakeqs.organd help
> > others with their CakePHP related questions.
>
> > You received this message because you are subscribed to the Google Groups
> > "CakePHP" group.
> > To post to this group, send email to cake-php@googlegroups.com
> > To unsubscribe from this group, send email to
> > cake-php+unsubscr...@googlegroups.com<cake-php%2bunsubscr...@googlegroups.com>For
> >  more options, visit this group at
> >http://groups.google.com/group/cake-php?hl=en
>
> Check out the new CakePHP Questions sitehttp://cakeqs.organd help others with 
> their CakePHP related questions.
>
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group 
> athttp://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to