Re: Setting variables in AppController to use in Layout.
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