Page 1 of 2

using a logout URL instead of button -- setting the result p

Posted: Thu Oct 16, 2008 7:37 am
by jonactionbase
I'm using Joomla! 1.5
I've been trying to set up a link to allow users to logout (instead of the logout button).

I've managed to do this, by pointing a menu item to:

Code: Select all

index.php?option=com_user&task=logout
joomla adds

Code: Select all

&Itemid=136
because it's a menu item.

With or without the itemid, the user is taken to a blank page. Since I'm not invoking the login module directly, I suppose that's why my settings aren't taken from there.

How do I get the user to the start page instead of an empty page?
Any ideas?

Re: using a logout URL instead of button -- setting the result p

Posted: Thu Oct 16, 2008 1:58 pm
by ooffick
As far as I know you will need to use a Form to submit this, as you need some of the hidden fields to logout.

Olaf

Re: using a logout URL instead of button -- setting the result p

Posted: Thu Oct 16, 2008 2:11 pm
by jonactionbase
Hi, olaf.

Thanks, but I've managed to logout successfully.
It's the page I'm taken to that is bothering me.

However, maybe a form is the way to go in order to tell Joomla what to do. I'll put a link with a POST method.
But then I need to process the form, which I'm not sure what to do with.

Now I just need to figure out how to do that.

Anyone got an idea?

J.

Re: using a logout URL instead of button -- setting the result p

Posted: Thu Oct 16, 2008 2:15 pm
by ooffick
well, you might want to try to add the hidden base64 encoded return URL parameter as well, I am not sure if you used that.

Olaf

Re: using a logout URL instead of button -- setting the result p

Posted: Thu Oct 16, 2008 3:37 pm
by jonactionbase
ooffick wrote:well, you might want to try to add the hidden base64 encoded return URL parameter as well, I am not sure if you used that.

Olaf
I didn't use a form at all.

I created a menu with a single menu item, of a "link" type, that points to the logout url.

Should I replace this with a custom html module and write a small form, with a link and "post" method?

J.

Re: using a logout URL instead of button -- setting the result p

Posted: Thu Oct 16, 2008 3:48 pm
by ooffick
Sorry, what I meant was add the parameter return=[your-base64-encoded-return-URL] so your URL looks like this:

Code: Select all

index.php?option=com_user&task=logout&return=L2luZGV4LnBocD90cD0x
Olaf

Re: using a logout URL instead of button -- setting the result p

Posted: Thu Oct 16, 2008 3:59 pm
by jonactionbase
ooffick wrote:Sorry, what I meant was add the parameter return=[your-base64-encoded-return-URL] so your URL looks like this:

Code: Select all

index.php?option=com_user&task=logout&return=L2luZGV4LnBocD90cD0x
Olaf
Oooooh. Sweet.
I'll have to try this next week.

Thanks a mil, Olaf!

Re: using a logout URL instead of button -- setting the result p

Posted: Thu Oct 23, 2008 9:36 am
by jonactionbase
ooffick wrote:Sorry, what I meant was add the parameter return=[your-base64-encoded-return-URL] so your URL looks like this:

Code: Select all

index.php?option=com_user&task=logout&return=L2luZGV4LnBocD90cD0x
Olaf
Okay, I tried playing around with this, but it didn't work out.

a. I'm either not properly encoding my URL.
b. Joomla doesn't automatically decode the URL (would I need to parse it myself in PHP?)
c. I'm completely off target.

How should I encode the URL? Should I do it once, and then paste the code into the return parameter?

Should I still be using a menu with a link, or should I render my own <div> with a link inside?

Thanks for your help.

Re: using a logout URL instead of button -- setting the result p

Posted: Thu Oct 23, 2008 10:16 am
by ooffick
Which Joomla version do you use?
Which URL do you want to link to?

Olaf

Re: using a logout URL instead of button -- setting the result p

Posted: Thu Oct 23, 2008 11:40 am
by jonactionbase
I'm using Joomla 1.5

I'd like the logout link to go to the homepage when clicked.

I tried encoding "/".

I tried encoding the full URL (it's on our intranet).
I tried using the encoder I foundwhile googling the subject.

Re: using a logout URL instead of button -- setting the result p

Posted: Thu Oct 23, 2008 12:23 pm
by ooffick
Can you try this one:

Code: Select all

index.php?option=com_user&task=logout&return=aW5kZXgucGhw
Do you have access to your error log file? to see if there are any errors? Do you have PHP4 or PHP5?

Olaf

Re: using a logout URL instead of button -- setting the result p

Posted: Thu Oct 23, 2008 12:32 pm
by jonactionbase
1. You ROCK. It works.
2. What did you do, and how would I go about doing it myself, in the future?
Ah... I see

Code: Select all

"aW5kZXgucGhw" = index.php
ok. But then, what if I want to use SEF URLs?

3. We're using PHP5. Is there something specific you're interested in from the error log?

Re: using a logout URL instead of button -- setting the result p

Posted: Thu Oct 23, 2008 12:33 pm
by jonactionbase
jonactionbase wrote: ok. But then, what if I want to use SEF URLs?

You encode the name of the page you'd like to go to, genius.

But really, what if I just want it to go to the root...?

Re: using a logout URL instead of button -- setting the result p

Posted: Thu Oct 23, 2008 12:43 pm
by ooffick
The index.php file is the root.
SEF is not a problem as the other files work as the SEF file works as well.

But you could also try this one:

Code: Select all

index.php?option=com_user&task=logout&return=Lw
Olaf

Re: using a logout URL instead of button -- setting the result p

Posted: Thu Oct 23, 2008 12:58 pm
by jonactionbase
Aaah.

'cos the calculator kept encoding "/" it as "Lw==" and I couldn't find a way to encode the URL properly.

Great.

Now All Is Well.

Thanks again, Olaf!

J.

Re: using a logout URL instead of button -- setting the result p

Posted: Sat Jan 31, 2009 4:39 am
by Dynamic Fun
ooffick wrote:The index.php file is the root.
SEF is not a problem as the other files work as the SEF file works as well.

But you could also try this one:

Code: Select all

index.php?option=com_user&task=logout&return=Lw
Olaf
This is exactly what I came searching to find today.
Thank you. :)

Re: using a logout URL instead of button -- setting the result p

Posted: Wed Feb 04, 2009 3:50 pm
by Whitebread
Thats awesome!
I had completely forgot that I was trying to do this. It works great, thanks for the posts!

Re: using a logout URL instead of button -- setting the result p

Posted: Wed Feb 04, 2009 4:49 pm
by tr2n
Great, it works just fine, thanks!

Re: using a logout URL instead of button -- setting the result p

Posted: Wed Feb 11, 2009 1:31 pm
by JuanOrtiz
Hey everybody! this post helped me a lot!
Here you can encode text to 64:
http://www.motobit.com/util/base64-decoder-encoder.asp

Re: using a logout URL instead of button -- setting the result p

Posted: Wed Mar 25, 2009 4:58 pm
by marahibsat
I want only to thank Olaf as he saved me time today, he gave two solutions, one on my thread and this one for url to logout
You are so loved Olaf, if you need help in satellite just google my name

marahibsat

Re: using a logout URL instead of button -- setting the result p

Posted: Mon May 11, 2009 10:19 am
by selimoff
Olaf, Joomla Hero!!!
Thanks

Re: using a logout URL instead of button -- setting the result p

Posted: Thu May 21, 2009 5:03 pm
by agarza
Life saver! Exactly what I was looking for. :D :D :D

Thanks Olaf

Re: using a logout URL instead of button -- setting the result p

Posted: Sat Jun 13, 2009 12:46 am
by MAD King
Could anyone explain me how to do this?

I always get the Menu item number at the end of the link.

Thnx

Re: using a logout URL instead of button -- setting the result p

Posted: Sat Jun 13, 2009 8:33 am
by ooffick
You can set the URL yourself if you want to.

Olaf

Re: using a logout URL instead of button -- setting the result p

Posted: Sat Jun 13, 2009 2:24 pm
by MAD King
How?

Re: using a logout URL instead of button -- setting the result p

Posted: Sat Jun 13, 2009 2:37 pm
by tusker
is it working with SEF urls enabled?

Re: using a logout URL instead of button -- setting the result p

Posted: Sat Jun 13, 2009 2:39 pm
by ooffick
MAD King wrote:How?
Did you try the external link type in the Menu Item?
What exactly do you want to do anyway?

Olaf

Re: using a logout URL instead of button -- setting the result p

Posted: Sat Jun 13, 2009 2:52 pm
by MAD King
I want the logout link in the user menu. But when I use the external link option it gives me a item id at the end and that comes up with an error after clicking the link.

Re: using a logout URL instead of button -- setting the result p

Posted: Sat Jun 13, 2009 3:08 pm
by ooffick
Why don't you use the following:
  1. Go to the Menu Manager
  2. Find your Menu
  3. Click on the Edit Menu Items Icon
  4. Click on New
  5. Click on User
  6. Click on "Default Login Layout"
  7. set Access Level = Registered
  8. set title = "Logout"
  9. set alias = "Logout"
  10. set Logout Redirection URL to whatever URL you want e.g. /index.php
  11. Click on Save
Olaf

Re: using a logout URL instead of button -- setting the result p

Posted: Sat Jun 13, 2009 5:20 pm
by MAD King
Thank you. But is there a way if I click on the logout link that I looged out without redirect to the extra page with the logout button?