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

General questions relating to Joomla! There are other boards for more specific help on Joomla! features and extensions.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Locked
00ian
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Sat Apr 07, 2007 3:22 pm

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

Post by 00ian » Sat Apr 07, 2007 5:42 pm

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.

User avatar
Robin
Joomla! Master
Joomla! Master
Posts: 15753
Joined: Thu Aug 18, 2005 10:41 am

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

Post by Robin » Sun Apr 08, 2007 10:26 am

Moderator note; duplicate post removed, cross posting is not allowed according to forum rules.

User avatar
fairywitch
Joomla! Intern
Joomla! Intern
Posts: 87
Joined: Mon Jan 01, 2007 7:14 pm
Location: Germany
Contact:

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

Post by fairywitch » Sun Apr 08, 2007 10:32 am

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
+~* http://www.fairywitch.net/*~+ - Blog & some joomla! info
+~* http://beewitched.fairywitch.net*~+ Sims 1 downloads

00ian
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Sat Apr 07, 2007 3:22 pm

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

Post by 00ian » Sun Apr 08, 2007 6:40 pm

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.

00ian
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Sat Apr 07, 2007 3:22 pm

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

Post by 00ian » Tue Apr 10, 2007 3:31 pm

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?
Last edited by 00ian on Tue Apr 10, 2007 4:10 pm, edited 1 time in total.

hlarsen
Joomla! Apprentice
Joomla! Apprentice
Posts: 34
Joined: Fri Sep 15, 2006 6:46 pm

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

Post by hlarsen » Thu Apr 19, 2007 7:59 pm

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 -

nk
Joomla! Apprentice
Joomla! Apprentice
Posts: 6
Joined: Tue May 30, 2006 10:00 am

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

Post by nk » Fri Jul 06, 2007 8:00 am

Thank you, hlarsen

this was helpful.


Locked

Return to “General Questions - 1.0.x”