Page 1 of 1

How to make a login/logoff button?

Posted: Sat Oct 16, 2010 6:56 pm
by HTMLCSSNoob
Does anyone know how to make 1 login/logout link that changes depending on whether the customer is logged in or logged out?

I want to move the horizontal navigation menu to a Simple HTML module on the left hand sidebar, but not sure how to move the login/logout button. I'm attaching a picture to give an idea of what i'm trying to do...

Re: How to make a login/logoff button?

Posted: Sat Oct 16, 2010 7:46 pm
by qahar
on default2 i use something like this:

Code: Select all

		<?php if (!$logged) { ?>
		<a class="tr_login" href="<?php echo str_replace('&', '&', $login); ?>" title="<?php echo $text_login; ?>"><?php echo $text_login; ?></a>
		<?php } else { ?>
		<a class="tr_logout" href="<?php echo str_replace('&', '&', $logout); ?>" title="<?php echo $text_logout; ?>"><?php echo $text_logout; ?></a>
		<?php } ?>
but not tested yet on module

Re: How to make a login/logoff button?

Posted: Sun Oct 17, 2010 12:37 am
by HTMLCSSNoob
qahar wrote:on default2 i use something like this:

Code: Select all

		<?php if (!$logged) { ?>
		<a class="tr_login" href="<?php echo str_replace('&', '&', $login); ?>" title="<?php echo $text_login; ?>"><?php echo $text_login; ?></a>
		<?php } else { ?>
		<a class="tr_logout" href="<?php echo str_replace('&', '&', $logout); ?>" title="<?php echo $text_logout; ?>"><?php echo $text_logout; ?></a>
		<?php } ?>
but not tested yet on module
Hey, thanks for that qahar. One question though, were would I try out your code above? What folder and file?

Re: How to make a login/logoff button?

Posted: Sun Oct 17, 2010 8:20 am
by jones
in default theme that located at header.tpl and you can put it at your Main Menu .tpl file, i assume you place Main Menu Module at theme\YOUR_THEME\template\module\

Re: How to make a login/logoff button?

Posted: Mon Oct 18, 2010 10:08 pm
by HTMLCSSNoob
Hmm, thanks for the help guys, but unfortunately I can't paste php code in the html module (at least not anyway I know how).

Actually I want to move the whole horizontal navigation menu over to the left hand column. Have to play around with it a bit and see if I can figure it out. ???

Re: How to make a login/logoff button?

Posted: Tue Oct 19, 2010 12:08 pm
by jones
so let me see the codes of your Main Menu .tpl, just put it here and let me know where do you place your Main Menu .tpl file?

header.tpl located at
catalog\view\theme\YOUR_THEME\template\common\

Re: How to make a login/logoff button?

Posted: Tue Oct 19, 2010 4:05 pm
by HTMLCSSNoob
jones wrote:so let me see the codes of your Main Menu .tpl, just put it here and let me know where do you place your Main Menu .tpl file?

header.tpl located at
catalog\view\theme\YOUR_THEME\template\common\
Thanks jones,

My Main Menu is just a Simple HTML module. I got it from http://www.kreasimote.com/component/con ... ncart.html.

I put it at theme\YOUR_THEME\template\module\.

The code for the .tpl file is below:

Code: Select all

<div class="box">
  <div class="top">
	<?php
	  if($title) { ?>	
		<img src="catalog/view/theme/default/image/brands.png" alt="" /><?php echo $title; ?>
	<?php
	} ?>
  </div>
  <div class="middle" style="text-align: left;">
    <?php echo $code; ?>
  </div>
  <div class="bottom">&nbsp;</div>
</div>
I wanted to move my entire horizontal navigation menu into the module, but haven't figured out how to do it yet.... ???

Re: How to make a login/logoff button?

Posted: Tue Oct 19, 2010 8:04 pm
by jones
I think you already know the answered...

come on friend, don't waste your time :laugh:
then

Code: Select all

<?php echo $code; ?>
figured from admin module, right? so mean you able to input html code then output as html decode, but it can't accepted special chars of php without encode to ascii / numeric chars, it's hard to explain

at the end your module can't handle php code, so impossible you will run the php conditions

i see you were answer at http://forum.opencart.com/viewtopic.php?f=113&t=6864 (itu masih berhubungan lagi)

am i missing?

Re: How to make a login/logoff button?

Posted: Wed Oct 20, 2010 12:18 pm
by ifyouseek
If you copy the html from your mymodule in admin, then paste it into the mymodules .tpl file. Then replacing the login/logout links with the php code should work.

Code: Select all

<div class="box">
  <div class="top">
   <?php
     if($title) { ?>   
      <img src="catalog/view/theme/default/image/brands.png" alt="" /><?php echo $title; ?>
   <?php
   } ?>
  </div>
  <div class="middle" style="text-align: left;">

*****INSERT HTML & PHP HERE****

    <?php echo $code; ?>
</div>
  <div class="bottom">&nbsp;</div>
</div>

Re: How to make a login/logoff button?

Posted: Thu Oct 21, 2010 1:29 pm
by jones
Yea, it should work by inserting from .tpl file but not from form editor at admin module area...

and then if you do that, you need to tell the definition of if (!$logged), $text_login, $text_logout at your e.g. mymodule.php

Re: How to make a login/logoff button?

Posted: Fri Jun 10, 2011 6:52 am
by jcooke
Thanks for the script you gave earlier. My question is, how do you give this script a specific color?

<?php if (!$logged) { ?>
<a class="tr_login" href="<?php echo str_replace('&', '&', $login); ?>" title="<?php echo $text_login; ?>"><?php echo $text_login; ?></a>
<?php } else { ?>
<a class="tr_logout" href="<?php echo str_replace('&', '&', $logout); ?>" title="<?php echo $text_logout; ?>"><?php echo $text_logout; ?></a>
<?php } ?>


here is what I have now

<td width="150" align="left"><b><font color="#a6ee53" size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<?php if (!$logged) { ?>
<a class="tr_login" href="<?php echo str_replace('&', '&', $login); ?>" title="<?php echo $text_login; ?>"><?php echo $text_login; ?><span style="text-decoration: none"></span></b></a>
<?php } else { ?>
<a class="tr_logout" href="<?php echo str_replace('&', '&', $logout); ?>" title="<?php echo $text_logout; ?>"><?php echo $text_logout; ?><span style="text-decoration: none"></span></font></font></b></a>
<?php } ?>
</td>

Re: How to make a login/logoff button?

Posted: Mon Jun 13, 2011 6:30 am
by ifyouseek
Try that -

Code: Select all

<span style="text-align: left; color: #a6ee53; font-size: 14px; font-weight: bold;">

<?php if (!$logged) { ?>
<a class="tr_login" href="<?php echo str_replace('&', '&', $login); ?>" title="<?php echo $text_login; ?>"><?php echo $text_login; ?></a>
<?php } else { ?>
<a class="tr_logout" href="<?php echo str_replace('&', '&', $logout); ?>" title="<?php echo $text_logout; ?>"><?php echo $text_logout; ?></a>
<?php } ?>

</span>

Re: How to make a login/logoff button?

Posted: Mon Jun 13, 2011 8:15 pm
by jcooke
Thanks for the reply. I didn't even think to use a span.

Re: How to make a login/logoff button?

Posted: Tue Nov 15, 2011 8:25 pm
by emotioneu
i'm sorry for the "holy thread resurrection - batman!" - but i do need something very similar to what qahar first answered, but for 1.5.1.3 - default.

to me it seems as in the header.tpl neither $login nor $text_login seem to be available (as so for logout & logout_text)

could someone point me into the right direction?

thanks,

emo

Re: How to make a login/logoff button?

Posted: Wed Jan 18, 2012 10:50 am
by unetic
you could always just use a direct link,
<a href="<?php echo HTTP_SERVER . 'index.php?route=account/logout'; ?>">LOGOUT</a>
as i don't believe the login/logout location changes.

Mitchell Bray
http://www.echoedlight.com/