
A dynamic login and logout menu is something that is somewhat hard to come by in the Joomla world. There is no way to do it through any module settings nor is there a solid solution on any forums. Well i have searched time and time again to find the answer only to end up more frustrated and confused. I have finally found a decent and easy solution(kinda). The solution is MetaMod. This extremely versatile module can really help you out when i comes to making dynamic time and ACL control over your modules. This tutorial is about one of those things that you always think you have figured out and then you realize you just spent 2 hours chasing the wrong thing. Ring any bells? I know because I have spent hours trying to find a quality solution to this problem.
SO, essentially what we are talking about is a way to make your menu say logout when you are logged in and login when you are logged it. Pretty simple right? Well based upon how many people ask how to do it I would say that it is a bit more difficult than that. Sure you can use PHP to control it using Jfactory but for those who do not know PHP or much code for that matter, here is an easier solution.
First, you need to head on over to http://www.metamodpro.com/ and download the latest version of MetaMod. Go ahead and install it onto your Joomla website.
Now, the way that MetaMod controls the wording is by hiding one menu, when you login, and showing another menu that contains logout. You are going to need to make a duplicate of the menu that has your login/logout item on it.
Now that you have your menus set up you need to make sure that they are un-published in the same module position.
This is where you use MetaMod. Go and find MetaMod in your module manager and set it to published in the same position as your menus. Okay, so it looks like a lot of parameters for MetaMod but you really need to do 2 things. Go to Style for Included Modules and set that to Naked - no div, no title. Then you need to add the only bit of code you need. Inside of the text area PHP copy and paste this 1 line of code: if (MM_LOGGED_IN) return 93; else return 83;
The only change you need to make is to the numbers. The numbers are the module id's to find them go to your module manager and look all the way to the right to see what the id is for your 2 menu modules. The first number in the code is for your menu that has logout on it. The menu with login is the second number.
All this code is saying is that if the user is a guest then show the login menu and if they are a member then show the logout menu.
There are some complications that can make this tricky to use. For instance if you have any module chromes in your template that you want to include make sure that you use that setting in MetaMod. Another problem that can occur is some weird padding issues, you can override this with CSS if you know what you are doing.
Well that is pretty much it hopefully this wasn't to hard to follow and for non-coders it is a great solution.
Comments (1)
MacPhotoBiker