In Joomla prior to 1.6 i could set a menu-item to public, and its contents: an article for example to registered.
This lead to a situation where people could see the link to an article in the menu when not logged in, but got a login component whenever they clicked it. And after that they saw the article.
In 1.7 these same actions lead to a situation where when I click the link the component screen just stays empty.
How do I get registered articles to show a login screen when the front end user is not logged in with sufficient rights? It was soo easy before and I can't seem to get it to work now.
If what you want is just to show a content if the visitor is a registered user, you can use this code:
Hope that helps!!
Im gonna answer my own question, because Im sure people will need this in the future, and my solution only involves a few rules of extra code and then you can set every article etc... to Registered and you'll see a login field when a user is not logged in.
In your templates index.php place this near the top, it gets your article's access level.
Then add a module position above your component, and only show it when your needed access level is > 1
Then add a login module in your module manager to LOGIN_MODULE_POSITION.
Voila... no routing needed etc... everything works out of the box, I chose to style away the logout box and action field like this:
Good luck!
Go menu CONTENT, create or edit a section to the items you want to protect.
You'll see an option: Access Level
There is 3 options:
Public, Registered and Special
Set it to: Registered
Then you'll need to change your articles for this section and that's all.
Create your "real" menu (for example, "main menu") and the menu item that will display for all users (for example "Submit an Article"). The menu item will have a menu item type of "Alias". It's "Menu Item" parameter will be the "Submit an Article" menu item on the "hidden menu". The Access Level for this menu item will be "Public", since we want everyone to be able to see and use it.
Create a module of type "mod_mainmenu" for this menu, just like you do for any menu.
Now, when a guest (non-logged-in user) accesses the "Submit an Article" menu choice, it redirects them to blank page with the "Only for registred visitors" message. . If they log in successfully, they are taken to the desired page (in this case, "Submit an Article"). If there were already logged in, they go there directly.
First of all you have to update your joomla installation to 2.5 (it's the latest version of joomla), 1.7 is no more supported by Joomla community.
There are several ways to set your viewing rights. K2 is a useful CCK component to do the job, also a useful technique that I use to follow is to "link" your article's categories in a menu and set specific permissions to the menu items