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.