Zend Framework 2 - Hide login link when logged in and vice versa for logout -


i'm pretty new zf2 , i'm trying find simple way allow login link hidden within view user has been logged in, , show again when user logs out. have taken @ zf2's acl examples, still little confused , unsure if needed achieve such simple thing.

if share knowledge on how done, eternally greatful. thank you

the standard identity view helper can this. work out of box if add authentication service service manager, instance in module's config/module.config.php this:

/* configuration omitted */  return array(     'service_manager' => array(         'zend\authentication\authenticationservice' => function($sm) {             $authservice = new \zend\authentication\authenticationservice();             $authservice->setstorage(new \zend\authentication\storage\session('user', 'details'));              return $authservice;         },     ), ); 

then can in view script:

if ($this->identity() == null) {     // user not logged in; show login link here }  else {     // user logged in; show profile link here or nothing } 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

ios - iPhone/iPad different view orientations in different views , and apple approval process -

Shrink a YouTube video to responsive width -