How to make a link connect/disconnect for user[solved]

How to make a link connect/disconnect for user[solved]

Wednesday 17 May 2006 6:01:54 am - 3 replies

Modified on Thursday 18 May 2006 3:03:58 am by Coulibaly Ibrahim

Author Message

Raymond Williams

Wednesday 17 May 2006 10:07:04 am

Coulibaly,

If I understand correctly, you're wanting to show the "Connect" button if no user is logged in, and show the "Disconnect" button if a user is logged in. Yes?

Assuming the above, I believe something like the below would work.


{def $user=fetch( 'user', 'current_user' )}

{section show=eq($user.contentobject.name, 'Your Anonymous User Name')}
   // User is not logged in, Connect button code here (input, a href, whatever)
{section-else}
   // User is logged in, Disconnect button code here (input, a href, whatever)
{/section}

Put that where the button should show up.

Reference:
http://ez.no/doc/ez_publish/technical_manual/3_6/reference/modules/user/fetch_functions/current_user

Coulibaly Ibrahim

Thursday 18 May 2006 1:03:53 am

yes it's exactly what i wanted.

thanks.

Kristian Hole

Thursday 18 May 2006 2:24:36 am

I would recommend doing something like this:

{def $user=fetch( 'user', 'current_user' )}  
{if $user.is_logged_in}  
  // User is logged in, Disconnect button code here (input, a href, whatever)
  <a href={"/user/logout"}>Log out ({$user.contentobject.name})</a>
{else}
   // User is not logged in, Connect button code here (input, a href, whatever)
  <a href={"/user/login"}>Log in</a>
{/if}

Anonymous user is marked as not logged in.

Kristian

http://ez.no/ez_publish/documenta...tricks/show_which_templates_are_used
http://ez.no/doc/ez_publish/techn...te_operators/miscellaneous/attribute

You must be logged in to post messages in this topic!

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.