I need a display element according to whether the user is logged or not - In CakePHP 2.0
This does not work
<?php
if ($this->Auth->loggedIn()
{
echo $this->element('user');
}
else
{
echo $this->element('guest');
}
?>
Thanks
Follow the MVC pattern and put the logic in the controller.
In the controller:
$this->set( 'loggedIn', $this->Auth->loggedIn() );
In the view:
if( $loggedIn ) {
echo $this->element( 'user' );
}
else {
echo $this->element( 'guest' );
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With