Author Topic: SIMPLE-but-Custom Login / Logout Link - VirtueMart  (Read 10837 times)

emeelio

  • Jr. Member
  • **
  • Posts: 63
SIMPLE-but-Custom Login / Logout Link - VirtueMart
« on: July 10, 2011, 02:07:43 am »
Hi guys,

I want to create a simple Login / Logout link on my website which runs under VirtueMart. The system is simple:

Users not logged in see "LOGIN"
Users logged in see "LOGOUT"

I find a post for the Joomla! Login Module: http://forum.joomla.org/viewtopic.php?p=885685 but it obviously does not work with VirtueMart.

I will be using one of those modules that let you add PHP to a module.

What is the right code for this?

THANKS!  :)

TonyG

  • Jr. Member
  • **
  • Posts: 339
Re: SIMPLE-but-Custom Login / Logout Link - VirtueMart
« Reply #1 on: July 10, 2011, 10:43:28 am »
Hi
Simply use VMs login module. Look in the bundle of modules that comes with Virtuemart (if you download the complete package), you'll find a login module. Install, enable and publish it at your desired module position.

Hope this helps

emeelio

  • Jr. Member
  • **
  • Posts: 63
[SOLVED] SIMPLE-but-Custom Login / Logout Link - VirtueMart
« Reply #2 on: July 11, 2011, 18:57:52 pm »
Hi Tony!

I know VirtueMart inside out and your suggestion would be good for someone who does not mind to have this module on. I'm not interested in that. I needed the correct PHP code to make this work and I finally did it.

First, you need to download Jumi for Joomla! so it allows PHP withing your module. Then copy and paste the code below and customize the CSS to suit your needs:

Code: [Select]
<div id="your_id" style="your:stye">
<?php
$user 
=& JFactory::getUser();
if (!
$user->guest) {
echo 
'<a href="index.php?option=com_user&task=logout&return=Lw">Logout</a>';
} else {
echo 
'<a href="index.php?page=account.index&option=com_virtuemart">Login</a>';
}
?>

</div>




mikeoflondon

  • Beginner
  • *
  • Posts: 3
Re: SIMPLE-but-Custom Login / Logout Link - VirtueMart
« Reply #3 on: July 12, 2011, 14:28:36 pm »
This link  href="index.php?page=account.index&option=com_virtuemart" seems to be the link for maintenance of your account after you've logged in, rather than to a nice login script.

I made my own solution to this.  My solution:
1) Create a new menu called 'hidden' with one menu-item called 'log-in'. Set the associated module to show in no menu-items.
The page for this menu-item should be one with no content.  It will be your user's login page.
2) Use the Virtuemart login module, but set only to shoe on the log-in menu-item, in a position of your choice (I suggest below the main content).
3) the href you need for your login button is now just the log-in menu-item page.  (I'm using SEF on my site so for me it's BASEURL/log-in.
HTH,
Mike

emeelio

  • Jr. Member
  • **
  • Posts: 63
Re: SIMPLE-but-Custom Login / Logout Link - VirtueMart
« Reply #4 on: July 12, 2011, 18:19:59 pm »
This link  href="index.php?page=account.index&option=com_virtuemart" seems to be the link for maintenance of your account after you've logged in, rather than to a nice login script.

I made my own solution to this.  My solution:
1) Create a new menu called 'hidden' with one menu-item called 'log-in'. Set the associated module to show in no menu-items.
The page for this menu-item should be one with no content.  It will be your user's login page.
2) Use the Virtuemart login module, but set only to shoe on the log-in menu-item, in a position of your choice (I suggest below the main content).
3) the href you need for your login button is now just the log-in menu-item page.  (I'm using SEF on my site so for me it's BASEURL/log-in.
HTH,
Mike

Yes, that link takes you to the "maintenance" area and guess what happens if you are NOT logged in? It prompts you to login!

The solution you suggest makes no sense to me, and it won't be natural to most people, because once you log in you will have to go back to a page to log out. Let me repeat that guys: to log out you need to go to a page and click and extra button. You will realize about it out sooner or later, if you haven't, as I have done it before too. I will also be customizing the PHP file for this page so there is a registration area besides the already-existing area.

The best about my solution is that the login link turns into log out when you are, well, in. Try to do that with the module way (you can't). When I started working with VirtueMart this was the best option because I could do it but as I grew as a web designer I realized this was not a good way to do it from a well-designed-website stand point.

mikeoflondon

  • Beginner
  • *
  • Posts: 3
Re: SIMPLE-but-Custom Login / Logout Link - VirtueMart
« Reply #5 on: July 13, 2011, 19:30:29 pm »
I wasn't clear.
I DO use something similar to your code, so for logout it's only one click.  But I use my href for login.
However while logged in I also display a link called "Update my account" which is a link to the account.index page.
I didn't like to use this for login as (for me at least) the page then displays a confusing error message "Error: You do not have permission to access the requested module." and doesn't have the useful "No account yet? Register" option displayed.  I agree you can customise the php file, but it's already there in the VM login module.


emeelio

  • Jr. Member
  • **
  • Posts: 63
Re: SIMPLE-but-Custom Login / Logout Link - VirtueMart
« Reply #6 on: July 14, 2011, 20:10:52 pm »
I wasn't clear.
I DO use something similar to your code, so for logout it's only one click.  But I use my href for login.
However while logged in I also display a link called "Update my account" which is a link to the account.index page.
I didn't like to use this for login as (for me at least) the page then displays a confusing error message "Error: You do not have permission to access the requested module." and doesn't have the useful "No account yet? Register" option displayed.  I agree you can customise the php file, but it's already there in the VM login module.

In that case I do agree with you. What I will do is to remove that particular message and problem solved but now I see your solution is as good as mine. Good job! :O)

sanket1992

  • Beginner
  • *
  • Posts: 2
Re: SIMPLE-but-Custom Login / Logout Link - VirtueMart
« Reply #7 on: July 16, 2012, 15:31:14 pm »
I can't logout from virtuemart