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

Author Message

Coulibaly Ibrahim

Wednesday 17 May 2006 6:01:54 am

Hello all
i'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

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

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

eZ debug

Timing: Jan 19 2025 00:20:11
Script start
Timing: Jan 19 2025 00:20:11
Module start 'layout'
Timing: Jan 19 2025 00:20:11
Module start 'content'
Timing: Jan 19 2025 00:20:11
Module end 'content'
Timing: Jan 19 2025 00:20:11
Script end

Main resources:

Total runtime0.8142 sec
Peak memory usage4,096.0000 KB
Database Queries62

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0073 588.0547152.6406
Module start 'layout' 0.00730.0037 740.695339.4766
Module start 'content' 0.01110.8016 780.1719581.5938
Module end 'content' 0.81270.0015 1,361.765612.1250
Script end 0.8142  1,373.8906 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00350.4240160.0002
Check MTime0.00140.1714160.0001
Mysql Total
Database connection0.00160.192810.0016
Mysqli_queries0.757693.0457620.0122
Looping result0.00070.0840600.0000
Template Total0.766094.120.3830
Template load0.00240.291820.0012
Template processing0.763693.780020.3818
Template load and register function0.00040.047510.0004
states
state_id_array0.00410.507010.0041
state_identifier_array0.00230.280920.0011
Override
Cache load0.00210.2589250.0001
Sytem overhead
Fetch class attribute can translate value0.00060.077230.0002
Fetch class attribute name0.00130.156350.0003
XML
Image XML parsing0.00100.124430.0003
class_abstraction
Instantiating content class attribute0.00000.001450.0000
General
dbfile0.00160.1946160.0001
String conversion0.00000.001140.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
4content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
3content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
8content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
2content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 20
 Number of unique templates used: 7

Time used to render debug report: 0.0002 secs