Add a login/logout link

Author Message

Franck T.

Thursday 29 July 2004 8:39:26 am

In my pagelayout.tpl , I'd like to add a login/logout link (I need it in all my pages).
I've tried this but I get some errors:

<!-- Main menu table -->
            <table cellspacing="0" cellpadding="0" class="menu">
                <tr>
                    <td><a href={"/"|ezurl}>Home</a></td>
		    <td><a href={"/news"|ezurl}>News</a></td>
		    <td><a href={"/membres"|ezurl}>Memberss</a></td>
		    <td><a href={"/guestbook"|ezurl}>Guestbook</a></td>
		    <td><a href={"/links"|ezurl}>Links</a></td>
                    <td><p class="menuitem">
                      {section show=eq($current_user.contentobject_id,$anonymous_user_id)}
<a href={"/user/login/"|ezurl}> Login </a>
                    {section-else}
<a href={"/user/logout/"|ezurl}> Logout </a> 
                    {/section}
                    </p></td>
                </tr>
            <!-- End of main menu table -->

Can someone tell me how to realize this. May be there is another way ?
Thanks.

Eivind Marienborg

Thursday 29 July 2004 8:50:34 am

Have you tried printing the £current_user.contentobject_id and $anonymous_user_id to see if they match?

Anyways, EZ has a built-in function to check for login: http://ez.no/ez_publish/documentation/reference/data_fetching/user/is_logged_in . It might work using that.

Eivind

Bruce Morrison

Thursday 29 July 2004 4:14:27 pm

Try this. I've used if before

{let thisuser=fetch('user','current_user')}
  {section show=$thisuser.is_logged_in}
<p>Welcome. You are logged in as {$thisuser.contentobject.name}</p>
<p><a href={"/user/logout"|ezurl}>Logout</a></p>
  {section-else}
  
<p><a href={"/user/login/"|ezurl}> Login</a></p>                                                                                
  
  {/section}
{/let}
</div>

Cheers
Bruce http://www.designit.com.au/

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

Franck T.

Friday 30 July 2004 12:29:16 am

Yeah, it works fine.
Thanks a lot for your help.

Regards,

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 03:15:24
Script start
Timing: Jan 19 2025 03:15:24
Module start 'layout'
Timing: Jan 19 2025 03:15:24
Module start 'content'
Timing: Jan 19 2025 03:15:24
Module end 'content'
Timing: Jan 19 2025 03:15:24
Script end

Main resources:

Total runtime0.0232 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0063 589.1250152.6094
Module start 'layout' 0.00630.0028 741.734439.4141
Module start 'content' 0.00910.0115 781.148493.3984
Module end 'content' 0.02070.0025 874.546934.3047
Script end 0.0232  908.8516 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002410.3126140.0002
Check MTime0.00114.8716140.0001
Mysql Total
Database connection0.00156.566610.0015
Mysqli_queries0.002611.183730.0009
Looping result0.00000.051310.0000
Template Total0.00219.110.0021
Template load0.00083.653710.0008
Template processing0.00135.444110.0013
Override
Cache load0.00062.555810.0006
General
dbfile0.003314.042380.0004
String conversion0.00000.040040.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs