Top Login box

Author Message

Neo Pixel

Wednesday 18 February 2009 8:35:24 am

Hi,

I've designed an ezpublish site with a login box at the top using the form from the login page.

ie:

Username: TEXTBOX
Password: TEXTBOX
forgotten password <-- link

Once a user logs into their account is it possible for the form to be replaced with the logout link?

How would I go about doing this?

Thanks in advance :-)

Asking stupid questions so you don't have to!

Norbert Wagner

Wednesday 18 February 2009 8:55:25 am

You could check wich user is actually logged in, if it is the anonymous user show the login form, else the logout link.

Regards,
Norbert

Neo Pixel

Wednesday 18 February 2009 10:40:52 am

Hi Norbert,

Yes that's what I am after but how do I achieve it?

Do I need to create a .tpl file and reference it in the pagelayout.tpl

if so, what code do I put into the new loginbox.tpl ?

Asking stupid questions so you don't have to!

Norbert Wagner

Wednesday 18 February 2009 12:33:17 pm

You can put everything right inside the template where you put the form.
Just use a if statement like

{if eq(user,anonymous)}
// form code here
{else}
// logout
{/if}

Check the manual for how to get the current user, perhaps there is a pagelayout variable?

Norbert

Yannick Komotir

Friday 20 February 2009 4:18:02 am

Hi,

  {if $current_user.is_logged_in}
     <a href={"/user/logout"|ezurl} >Logout</a>
  {else}
     {*your login form here*}
  {/if}
 

<|- Software Engineer @ eZ Publish developpers -|>
@ http://twitter.com/yannixk

Neo Pixel

Saturday 21 February 2009 10:07:00 am

Thanks Yannick that works perfectly!


{if $current_user.is_logged_in}      
	<a href={"/user/logout"|ezurl} >Logout</a>   
	{else}      
	
<form method="post" action="/eng/user/login" name="loginform">
<table cellpadding="5" cellspacing="5" width="250">
<tr>
	<td align="right">Username</td>
	<td><input class="box" type="text" size="15" name="Login" id="id1" value="" tabindex="1" /></td>
</tr>
<tr>
	<td align="right">Password</td>
	<td><input class="box" type="password" size="15" name="Password" id="id2" value="" tabindex="1" /></td>
</tr>
<tr>
	<td align="right">&nbsp;</td>
	<td><input class="defaultbutton" type="submit" name="LoginButton" value="Login" tabindex="1" /> <a href="/eng/user/forgotpassword">forgotten password?</a></td>
</tr>
</table>
</form>	

   {/if} 

Asking stupid questions so you don't have to!

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 18 2025 21:01:37
Script start
Timing: Jan 18 2025 21:01:37
Module start 'layout'
Timing: Jan 18 2025 21:01:37
Module start 'content'
Timing: Jan 18 2025 21:01:37
Module end 'content'
Timing: Jan 18 2025 21:01:37
Script end

Main resources:

Total runtime0.6699 sec
Peak memory usage4,096.0000 KB
Database Queries68

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0055 587.7891152.6094
Module start 'layout' 0.00550.0032 740.398439.4141
Module start 'content' 0.00870.6598 779.8125610.7188
Module end 'content' 0.66840.0014 1,390.531316.1953
Script end 0.6699  1,406.7266 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00320.4791160.0002
Check MTime0.00140.2034160.0001
Mysql Total
Database connection0.00090.136710.0009
Mysqli_queries0.609290.9294680.0090
Looping result0.00060.0953660.0000
Template Total0.643496.020.3217
Template load0.00210.309320.0010
Template processing0.641395.725320.3206
Template load and register function0.00010.012110.0001
states
state_id_array0.00060.096710.0006
state_identifier_array0.00100.145720.0005
Override
Cache load0.00180.2673380.0000
Sytem overhead
Fetch class attribute can translate value0.00080.116130.0003
Fetch class attribute name0.00100.154680.0001
XML
Image XML parsing0.00250.372930.0008
class_abstraction
Instantiating content class attribute0.00000.0030100.0000
General
dbfile0.00240.3529230.0001
String conversion0.00000.001540.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/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
6content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
9content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
4content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
3content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 28
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs