Re: Setting variables in AppController to use in Layout.
well,
beforeFilter() is not always triggered
why not putting everything in beforeRender()
would make more sense to me
by the way:
for some data you can always use Configure::write() and
Configure::load()
might make sense if you want to use it in different locations
On 10 Jul., 10:00, runckel <robhueb...@web.de> wrote:
> Hi,
>
> i dont see anything wrong there, so i would first write a $this-
> log($login_url) in the app controllers beforeRender to be sure it will
> be called and the $login_url is filled. One reason it will not be
> called could be a beforeRender in the calling Controller whitch doesnt
> call his Parent.
>
> On 8 Jul., 22:25, Angad Nadkarni <angad.nadka...@gmail.com> wrote:
>
>
>
>
>
>
>
> > I am setting variables in AppController in order to use them in
> > default.ctp.
>
> > This is my code:
>
> > function beforeRender ( )
> > {
> > @Controller::loadModel('User');
> > $login_url = [trimmed];
> > $this->set('loginurl', $login_url);
> > $this->set('user', $this->Cookie->read('User'));
> > $this->set('examdata', $this->User->query('select listing from exams
> > limit 0,1'));
> > $this->set('exam', $this->Cookie->read('exam'));
> > }
>
> > The logic for above code has been performed in beforeFilter().
>
> > Now when I use the variables in default.ctp, such as say $loginurl, or
> > $examdata, I get:
>
> > Undefined variable: loginurl
>
> > or Undefined variable: examdata
>
> > What am I doing wrong?
--
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
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home