I tried to use the menu to create a logout link.
Could someone paste the code to create such a link? forum/index.php?action=logout doesn't work, there's some session id stuff after it. I am not proficient enough to get the working link on my own. Please help!
You can't create a link like that in the menu manager. It requires the session ID to be added to the logout link which would be in the context array. In other words, you can't use PHP in the menu manager. You'll have to create a custom menu to do that in a block or something.
Yikes, Perhaps I could create a custom block just for that. What kind of code would be involved?
If you look at the logout button in the template_menu function in the index.template.php file you can see how the $context['session_id'] is added to the link.
Yes ok. So I'm looking at index template and here's the relevant code:
// Otherwise, they might want to [logout]...
if ($context['user']['is_logged'])
echo ($current_action == 'logout' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '"> </td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'logout' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=logout;sesc=', $context['session_id'], '">' , $txt[108] , '</a>
</td>' , $current_action == 'logout' ? '<td class="maintab_active_' . $last . '"> </td>' : '';
This is just too much junk. I don't want any of the maintab stuff. Just dumping all this into the php box does produce a logout button in some strange place but destroys the layout.
I need to refine this code.
The URL is here:
<a href="', $scripturl, '?action=logout;sesc=', $context['session_id'], '">' , $txt[108] , '</a>
But that alone gives me:
Parse error: syntax error, unexpected '<' in /home/.luther/generalsun/miydai/Sources/Load.php(1797) : eval()'d code(35) : eval()'d code on line 1
I'll experiment some more...
I really regret not knowing php fully. This is like groping in the dark...
If you hover over the logout button on your forum look down at the bottom left corner of the browser window and it will show you the url for the logout. Try that.
Edit : That will not work I dont think but try it
Ehh thanks, but read my first post, I've already tried something similar.
I just tried what I posted above and it works for me. I tried it under two different usernames and it worked fine
I'm sorry, could you post what link that was exactly?
I see forum/index.php?action=logout;sesc=somerandomjumbleoflettersandnumerals
As far as I know the last part is random and created upon logging in. I can't create a link based on that...
To be honest I wondered that myself. But I checked it with two different users and on two different login and cleared everything and it worked. But that is what I used.
Here's what i came up with (works fine in a PHP block)
Quote
global $context, $scripturl;
if ($context['user']['is_logged'])
echo '
<a href="', $scripturl, '?action=logout;sesc=', $context['session_id'], '">' , $txt[108] , '</a>';
Super duper! Thank you a great avalanche!
Quote from: Number7 on July 15, 2007, 06:34:12 AM
Here's what i came up with (works fine in a PHP block)
Quote
global $context, $scripturl;
if ($context['user']['is_logged'])
echo '
<a href="', $scripturl, '?action=logout;sesc=', $context['session_id'], '">' , $txt[108] , '</a>';
That's almost exactly what I was looking for...is there any way to execute that through the sitemap?
Let me explain...I want to eliminate the header all together and use the sitemap as the general navigation, to do this I want to add the logout to the sitemap as well but as we know the session ID makes it difficult. What I did with this code was insert it into an article and have the sitemap point to it but of course that just makes it a link to a link (redundancy, redundancy).
Perhaps this has been covered already somewhere on here, I'll keep digging but I found this code to be the best help so far.
hmmm... the Logout can be defined using SSI functions.
http://yoursite.com/ssi_examples.php
and
http://yoursite.com/ssi_examples.shtml
Your forum comes installed with working examples.
See SMF forums for more info on SSI functions.
Won't that again give me a link in the sitemap to a link in an article?
What I ended up doing is taking some code Bloc posted in another topic and I created another block directly below the sitemap, it's not perfect but it's better than having a link to a link to log out.
php block with no title but using the theme's frame
echo '<a href="index.php?action=logout;sesc='.$context['session_id'].'"><img src="http://www.pogochat.net/Themes/default/images/TPdivider.gif"/><b> Logout</b></a>';