Tuesday, 6 October 2015

 Dynamic Login/Logout in The Same Menu 


1.Go to Global Configuration and select DEFAULT ACCESS LEVEL as GUEST USERS.

2.Now that you have "guest" mode set up, you will create a menu item for the "Login" as you do usually (or edit your existing "login" if you have it already)

3.Set the Access Level to Guest. That way it will show up only to non-logged in users.

4.Now, the next step is to create a "Logout" menu item that will show only to "registered" users.

5.You can use this extension "Quick logout"for "Logout" a simple, one click process:

http://extensions.joomla.org/extensions/access-a-security/site-access/login-redirect/17971

This creates a new menu item type that gives a quick, no confirmation logout. 

6.Set the access level to be "Registered" and put it on the menu right next to your "Login" button.

The result is you have 2 menu items ... one for Login and one for Logout.

But, the Login button is only shown to non-logged in users, and the Logout button only appears to logged in users.

So, it appears to be a single menu item that "toggles" from "Login" to "Logout" ... but in reality is 2 different menu items. 

Now When you login you will be getting an error "You are not authorized to view this resource.

You just have to override the language file and edit the wording to whatever you want. The wording for that message is found in this file:

/languages/en-GB/en-GB.ini


Code:
JERROR_ALERTNOAUTHOR="You are not authorised to view this resource."  

(OR) you can do this more easily through a "Language Override." Here's how to do that.

Go to Extensions -> Language Manager

Click on "Overrides" and then click <New>.

On the next screen, enter the name of the message JERROR_ALERTNOAUTHOR and then the new message that you want to have Joomla display or even you can save it empty for no message.


No comments:

Post a Comment