Forums / General / Add a login/logout link

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,

eZ debug

Timing: Jan 19 2025 01:00:25
Script start
Timing: Jan 19 2025 01:00:25
Module start 'content'
Timing: Jan 19 2025 01:00:25
Module end 'content'
Timing: Jan 19 2025 01:00:25
Script end

Main resources:

Total runtime0.1564 sec
Peak memory usage2,048.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0062 588.8438180.8516
Module start 'content' 0.00620.0049 769.695397.9297
Module end 'content' 0.01110.1452 867.6250527.2344
Script end 0.1563  1,394.8594 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00372.3933200.0002
Check MTime0.00150.9685200.0001
Mysql Total
Database connection0.00080.509810.0008
Mysqli_queries0.105867.69221410.0008
Looping result0.00130.80741390.0000
Template Total0.144892.610.1448
Template load0.00070.450910.0007
Template processing0.144192.172810.1441
Override
Cache load0.00050.294810.0005
Sytem overhead
Fetch class attribute can translate value0.00080.532210.0008
XML
Image XML parsing0.00030.202210.0003
General
dbfile0.00905.7659200.0005
String conversion0.00000.003030.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/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