Forums / General / How to make a link connect/disconnect for user[solved]
Coulibaly Ibrahim
Wednesday 17 May 2006 6:01:54 am
Hello alli'd like to know how i can make a button, in the intranet part of my site to recognize user.
i want have a button <b>"connect"</b> if a user is connected and a button <b>"disconnect"</b> (<i>user</i>)
how can i do that?notice: the "button" can also be "links". it doesn't matter
thanks
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
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