at the beginning the had the same problems
the reason:
if an error is triggered, beforeFilter() and afterFilter() are not
invoked!
so everything you need in the layout should be in beforeRender()
this should be the case anyway
imagine you process some post data and redirect afterwards (or the
auth component redirects).
you would have fetched the data without beeing able to use it - as the
view is not needed on redirects.
so try to get view/page content as late as possible
and therefore in 9 out of 10 cases in beforeRender()
On 22 Dez., 14:55, NeoWebTech <deva.in...@gmail.com> wrote:
> I found an alternative solution by using beforeRender instead of
> beforeFilter
>
> And assigning `logged_in` in 'ObAuth' Comp.
>
> On Dec 20, 11:45 am, NeoWebTech <deva.in...@gmail.com> wrote:
>
> > Hello!
>
> > I am PHP Developer for some time and developing my second CakePHP App
> > now :)
>
> > I am getting the following error when I access $logged_in from
> > default.ctp.
>
> > Notice (8): Undefined variable: logged_in [APP\views\layouts
> > \default.ctp, line 17]
>
> > Also this happens only when no corresponding action defined in
> > controller which actually is 404 in production but I still want to
> > access the variable. How can I do this?
>
> > This the code in default.cpt
>
> > <?php e($logged_in); ?>
>
> > I set $logged_in AppController'sbeforeFilterfunction. Following the
> > whole code:
>
> > class AppController extends Controller {
>
> > var $components = array('ObAuth');
>
> > functionbeforeFilter() {
>
> > $this->set("logged_in", $this->logged_in);
>
> > return true;
> > }
>
> > }
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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
No comments:
Post a Comment