The Guest User Group - Hiding menu items and modules
Two weeks ago at JoomlaDay South Africa I gave the first presentation of my new talk "The Hidden Secrets of Joomla 1.7".
A lot of work went in to preparing that presentation and I hope to be taking it around the world in the coming months. (If you can't wait to see it live or for the video you can see the slides now.)
Reducing the "Hidden Secrets" to a 45 minute presentation sadly meant that some of them were dropped so I intend to write about them here instead.
Don't Make Them Think
How many web sites have you been to that has a menu link called Log in / Log out? You either want to log in or log out not both. With Joomla the actual link used for the login/logout is the same for both tasks and the action changes depends on the users status. Or seen a big module called Register Now when you are aready registered and logged in. How silly is that?
The Joomla 1.5 way
With 1.5 we were able to create a new menu link called Log out that was only displayed to users who were logged in but unless you installed some extensions it wasn't possible to then hide the link to Log in.
The same was true for modules. It was easy to set a module to only display to users who were logged in but you couldn't hide one for those users as the access rules were hierarchical.
So we either ended up with confusing links and unnecessary modules or alternatively added another extension for you to manage, configure and maintain.
The new Joomla 1.7 way
All of this has changed with Joomla 1.7 and it's new ACL (access control) functionality. We can now easily set items to display to guest users and to be hidden from logged in users.
Many people have heard me say that ACL is hard and as Jen Kramer says "Just because you can doesn't mean you should!!". But whilst I'm not a big fan of creating lots of permissions for who can create, edit or delete I do see a strong need for deciding who can see and what they can see.
Change the Guest User Group permissions
If you look in the User Manager options you will see not only a setting for the default group that registered users are placed in but also the default group for guests (non logged in users). As the Joomla 1.7 ACL is no longer hierarchical we can use this feature to create a new group at the same level in the ACL tree for guests.
- Create a Guest Group in the User Manager
- Add a new Guest Viewing Access Level
- Change the default guest group in the User Manager options
Assign menu links and modules
Now we can assign any menu link or module to the newly created Guest level and because it is at the same level in the ACL tree as Registered anything assigned to guest will not be visible to registered users.