Jump to content

Joomla: Changing menu item Login to Logout

From FVue

Problem

I have a menu item `Login' and I want this to change to `Logout' after user has logged in.

Solution

See forum thread How do I change menu item from login to logout after user logs in.
The golden tip is to create identical menus except for the Login/Logout menu item, and to switch between these two menus.

My steps to accomplish the Login/Logout menu, together with a 'full-page' Login:

Template Manager

  • { select template | `Edit HTML' }
  • insert this code in the template where you want the Login/Logout menu to appear:
<?php
    if ($my->id) {
        mosLoadModules ('TopReg');
    } else {
        mosLoadModules('TopGuest');
    } // if
?>
  • insert this code in the template where you want the login form to appear:
<?php mosLoadModules('user9'); ?>

Create two menus `topmenureg' and `topmenuguest' with identical menu items. Let the `topmenuguest' menu contain a menu item `Link - URL', titled `Logout' and linked to "index.php?option=logout".

Static Content Manager

Create a static content item `Login'. Within the `Static Content Item' page do:

  • { Title "Login" }
  • { tab `Link to Menu' | Menu Item Name "topmenuquest" | Link to Menu }

Site|Template Manager|Module Positions

Add positions "TopGuest" and "TopReg".

Module Manager

  • { select Module linked to type `mod_login' }
  • { Position: "user9" }
  • { select Pages/Items "topmenuguest | Login" | Save }
  • { select Module "Top Menu Guest" | position: "TopGuest" | published "Yes" | Save }
  • { select Module "Top Menu Registered" | position: "TopReg" | published "Yes" | Save }

Journal

20070922

Remove the Login Module *after* login
Tips for showing/hiding login and logout
How do I change menu item from login to logout after user logs in
Tip to create two menus with login/logout variants