Forums / Setup & design / Top Login box

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!

eZ debug

Timing: Jan 19 2025 00:57:30
Script start
Timing: Jan 19 2025 00:57:30
Module start 'content'
Timing: Jan 19 2025 00:57:30
Module end 'content'
Timing: Jan 19 2025 00:57:30
Script end

Main resources:

Total runtime0.1998 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.0074 588.8281180.8516
Module start 'content' 0.00740.0164 769.679797.9453
Module end 'content' 0.02380.1759 867.6250526.2266
Script end 0.1997  1,393.8516 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00361.7990200.0002
Check MTime0.00140.7046200.0001
Mysql Total
Database connection0.00080.421810.0008
Mysqli_queries0.121460.76501410.0009
Looping result0.00160.78381390.0000
Template Total0.175487.810.1754
Template load0.00080.406410.0008
Template processing0.174687.385510.1746
Override
Cache load0.00060.280810.0006
Sytem overhead
Fetch class attribute can translate value0.00150.734810.0015
XML
Image XML parsing0.00040.201610.0004
General
dbfile0.023811.9225200.0012
String conversion0.00000.004430.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