|
I'd like to put a logout link in my default layout. The link should be
there only when a user has already logged in. I put the following code in my app/views/layouts/default.ctp: if ($this->Auth->user()) echo $html->link('Logout', array('controller' => 'Users', 'action'=>'logout')); but, of course, cake didn't like and screamed in horror: Notice (8): Undefined property: View::$Auth [APP/views/elements/ logout.ctp, line 3] Fatal error: Call to a member function user() on a non-object in /app/ views/elements/logout.ctp on line 3 Is there a way to accomplish that? Thank you and Merry Christmas! maxx 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 [hidden email] To unsubscribe from this group, send email to [hidden email] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en |
|
in you app_controller.php, put this
public function beforeRender() { if (!array_key_exists('requested', $this->params)) { $user = $this->Session->read($this->Auth->sessionKey); $this->set(compact('user')); } } and in the layout put this if (!empty($user)) echo $html->link('Logout', array('controller' => 'Users', 'action'=>'logout')); and the happy new year On Dec 24, 4:46 am, emmexx <[hidden email]> wrote: > I'd like to put a logout link in my default layout. The link should be > there only when a user has already logged in. > I put the following code in my app/views/layouts/default.ctp: > > if ($this->Auth->user()) > echo $html->link('Logout', array('controller' => 'Users', > 'action'=>'logout')); > > but, of course, cake didn't like and screamed in horror: > > Notice (8): Undefined property: View::$Auth [APP/views/elements/ > logout.ctp, line 3] > > Fatal error: Call to a member function user() on a non-object in /app/ > views/elements/logout.ctp on line 3 > > Is there a way to accomplish that? > > Thank you and Merry Christmas! > > maxx 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 [hidden email] To unsubscribe from this group, send email to [hidden email] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en |
|
In reply to this post by emmexx-2
If(isset($this->Session->read('User.id'))):
> echo $html->link('Logout', array('controller' => 'Users', > 'action'=>'logout')); endif; happy christmas Em 24/12/2009, às 07:46, emmexx escreveu: > I'd like to put a logout link in my default layout. The link should be > there only when a user has already logged in. > I put the following code in my app/views/layouts/default.ctp: > > if ($this->Auth->user()) > echo $html->link('Logout', array('controller' => 'Users', > 'action'=>'logout')); > > but, of course, cake didn't like and screamed in horror: > > Notice (8): Undefined property: View::$Auth [APP/views/elements/ > logout.ctp, line 3] > > Fatal error: Call to a member function user() on a non-object in /app/ > views/elements/logout.ctp on line 3 > > Is there a way to accomplish that? > > Thank you and Merry Christmas! > > maxx > > 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 [hidden email] > To unsubscribe from this group, send email to > [hidden email] For more options, visit this > group at http://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 [hidden email] To unsubscribe from this group, send email to [hidden email] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en |
|
if($Session->read("User.id")) {
... } On Thu, Dec 24, 2009 at 8:30 AM, Edinei Luis Cipriani <[hidden email]> wrote: > If(isset($this->Session->read('User.id'))): >> echo $html->link('Logout', array('controller' => 'Users', >> 'action'=>'logout')); > > endif; > > > > happy christmas > > > Em 24/12/2009, às 07:46, emmexx escreveu: > >> I'd like to put a logout link in my default layout. The link should be >> there only when a user has already logged in. >> I put the following code in my app/views/layouts/default.ctp: >> >> if ($this->Auth->user()) >> echo $html->link('Logout', array('controller' => 'Users', >> 'action'=>'logout')); >> >> but, of course, cake didn't like and screamed in horror: >> >> Notice (8): Undefined property: View::$Auth [APP/views/elements/ >> logout.ctp, line 3] >> >> Fatal error: Call to a member function user() on a non-object in /app/ >> views/elements/logout.ctp on line 3 >> >> Is there a way to accomplish that? >> >> Thank you and Merry Christmas! >> >> maxx >> >> 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 [hidden email] >> To unsubscribe from this group, send email to >> [hidden email] For more options, visit this >> group at http://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 [hidden email] > To unsubscribe from this group, send email to > [hidden email] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en > -- Stefano Salvatori M. http://stefano.salvatori.cl/ 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 [hidden email] To unsubscribe from this group, send email to [hidden email] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en |
|
If($this->Session->read('User.id'))
would only be appropriate in cakephp 1.3! (in the view) On 24 Dez., 12:40, stefano <[hidden email]> wrote: > if($Session->read("User.id")) { > ... > > } > > On Thu, Dec 24, 2009 at 8:30 AM, Edinei Luis Cipriani > > > > <[hidden email]> wrote: > > If(isset($this->Session->read('User.id'))): > >> echo $html->link('Logout', array('controller' => 'Users', > >> 'action'=>'logout')); > > > endif; > > > happy christmas > > > Em 24/12/2009, às 07:46, emmexx escreveu: > > >> I'd like to put a logout link in my default layout. The link should be > >> there only when a user has already logged in. > >> I put the following code in my app/views/layouts/default.ctp: > > >> if ($this->Auth->user()) > >> echo $html->link('Logout', array('controller' => 'Users', > >> 'action'=>'logout')); > > >> but, of course, cake didn't like and screamed in horror: > > >> Notice (8): Undefined property: View::$Auth [APP/views/elements/ > >> logout.ctp, line 3] > > >> Fatal error: Call to a member function user() on a non-object in /app/ > >> views/elements/logout.ctp on line 3 > > >> Is there a way to accomplish that? > > >> Thank you and Merry Christmas! > > >> maxx > > >> 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 [hidden email] > >> To unsubscribe from this group, send email to > >> [hidden email] For more options, visit this > >> group athttp://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 [hidden email] > > To unsubscribe from this group, send email to > > [hidden email] For more options, visit this group athttp://groups.google.com/group/cake-php?hl=en > > -- > Stefano Salvatori M.http://stefano.salvatori.cl/ 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 [hidden email] To unsubscribe from this group, send email to [hidden email] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en |
|
How to do this in cakephp 1.2.5
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 [hidden email] To unsubscribe from this group, send email to [hidden email] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en |
| Powered by Nabble | Edit this page |
