How to change the 'login' menu item to 'logout' after the user has logged in?
I really struggled to find the solution for this. So here goes ...
I really struggled to find the solution for this. So here goes ...
Note: This solution is only for those users who want to use the Login link in the menu and connect it to the com_login in the main body of their joomla siteSummary:
- We will try and achieve the desired result by creating two similar menus and two module positions corresponding to each menu.
- The difference between the two will be that one has a Login link, the other has the Logout link.
- We will then insert a piece of code in the template to toggle between the menus based on user login.
- Go to Site, Template Manager, Module Positions
- Create 2 new module positions: pos_menuguest and pos_leftmenureg.
(These will be used to switch between the login and logout button) - Go to Menu, Menu Manager
- Create 2 Menu's: menuguest and menureg
- Go to Menu, menuguest
- Add the menu items you want shown when you are NOT logged in
- Make sure that your "Login" link is part of menuguest
- Go to Menu, menureg
- Add the content you want shown when you are logged in
- Make sure that the "Logout" link is part of menureg and Login IS NOT PART of menureg
- To ensure that there is no problem, change the Access Level of the Logout link to "Registered"
- Go to Modules, Site Modules, menuguest
- Assign it to position pos_menuguest
- Go to Modules, Site Modules, menureg
- Assign it to position pos_menureg
- Open your index.php of your template
(or go to Site > Template Manager > Site Template > Edit HTML) - Add the following in the appropriate place
(usually within the "left_inner" div or the position in your template where you want the menu to appear)
<?php if ($my->id) { mosLoadModules ('pos_menureg'); } else { mosLoadModules('pos_menuguest'); } ?>











0 comments:
Post a Comment