Page 1 of 1

How do I change menu item from login to logout after user logs in

Posted: Sat Apr 07, 2007 5:42 pm
by 00ian
Hi, this has probably already been answered but I have spent half a day searching the help files and forums with no success.  It is probably pretty simple HTML code but so far I cannot get anything to work.

How can I create a menu item which will display as "Login" when a user has not logged in and as "Logout" after a user has logged in?

I do not want to display the login form as static content, only the link on a menu.  The only way I have found is to create a new menu item for com_login with a static title.  I have been working on this off and on for four days now and am getting very frustrated.

Thanks for any help which anyone can give me.

Re: How do I change menu item from login to logout after user logs in

Posted: Sun Apr 08, 2007 10:26 am
by Robin
Moderator note; duplicate post removed, cross posting is not allowed according to forum rules.

Re: How do I change menu item from login to logout after user logs in

Posted: Sun Apr 08, 2007 10:32 am
by fairywitch
This thread may be of use to you, I used this myself for my site and it works flawlessly:

http://forum.joomla.org/index.php/topic,117512.0.html

Re: How do I change menu item from login to logout after user logs in

Posted: Sun Apr 08, 2007 6:40 pm
by 00ian
Thanks, That looks like exactly what I want.  :)

Sorry about the double posting but if you put something in the wrong category there does not seem to be any way to delete it.

Re: How do I change menu item from login to logout after user logs in

Posted: Tue Apr 10, 2007 3:31 pm
by 00ian
Now that I have had a chance to try this I find that it is not quite what I wanted.  I want would like is what appears to be a single item on a menu which changes from login to logout.  (The logout part works just fine).

Does anyone have any further ideas?

Re: How do I change menu item from login to logout after user logs in

Posted: Thu Apr 19, 2007 7:59 pm
by hlarsen
The solution I came up with (hat tip to other posters), was creating two almost identical menus: One for showing when you are not logged in (ie. containing a 'Login'-item) and one for showing when you are logged in (ie. containing a 'Logout'-item in the place where the 'Login'-item was) and then modifying the index.php of my template - Step by step it looks something like this:

In the backend:
  • Go to Site, Template Manager, Module Positions
  • Create 2 new module positions: TopGuest and TopReg
  • Go to Menu, Menu Manager
  • Create 2 Menu's: topmenuguest and topmenureg
  • Go to Menu, topmenuguest
  • Add the content you want shown when you are NOT logged in
  • Go to Menu, topmenureg
  • Add the content you want shown when you are logged in
  • Go to Modules, Site Modules, topmenuguest
  • Assign it to position TopGuest
  • Go to Modules, Site Modules, topmenureg
  • Assign it to position TopReg
  • Open your index.php of your template
  • Add the following in the appropriate place

Code: Select all

<?php
if ($my->id) {
  mosLoadModules ('TopReg');
} else {
  mosLoadModules('TopGuest');
}
?>
Further I've created a 'full-page' Login-page by: Creating a content-item, using mosmodule (from http://www.ongetc.com/) to include the Login-module in the content-item (just in case you wondered -  ;D) -

Cheers -

Re: How do I change menu item from login to logout after user logs in

Posted: Fri Jul 06, 2007 8:00 am
by nk
Thank you, hlarsen

this was helpful.