Page 1 of 1

Visible Menu Item - but need login to access

Posted: Fri Sep 28, 2012 8:28 pm
by ihtus
Hi,
I followed this tutorial about ACL - http://community.joomla.org/blogs/commu ... 6-acl.html

To make everything clear: this is what I need:

1. having a menu item that is linking to an article
2. a user enters (not logged yet) the web site (it does not matter if the user is already registered or not)
3. this user should see the menu item
4. the user clicks on the menu item
5a. if the user is NOT logged in - the user is asked to enter the username/pass
5b. if the user is logged in -> goto 6
6. after login is ok, the user can see the content of the article where the menu item was linked.

My aim is to have a menu item that would be visible for all users: logged in and not logged in. But when clicked - only logged in users can view the content where the menu item is pointing. In case the user is not logged in -> log in form should be displayed.

After following the above tutorial I got a menu item that is completely invisible for users that are NOT logged in.

How can I make the menu item to be visible for all, but need login to see content?

Thank you.

EDIT 1:

I just found this solution http://docs.joomla.org/Auto_redirect_guests_to_login
Is it the only solution? I have a huge tree menu structure. That means I need to have a clone of my huge menu... And everytime I change a menu item name - I should do it twice (in visible menu and in invisible menu).
Are there any other solutions without having 2 menus?

EDIT 2:

Found another solution (hacking core files).
This is when menu item is set to "public" but the article ACL is set to "registered"

components/com_content/views/article/view.html.php
from

Code: Select all

		// Check the view access to the article (the model has already computed the values).
		if ($item->params->get('access-view') != true && (($item->params->get('show_noauth') != true &&  $user->get('guest') ))) {

						JError::raiseWarning(403, JText::_('JERROR_ALERTNOAUTHOR'));

				return;

		}
to

Code: Select all

      // Check the view access to the article (the model has already computed the values).
      if ($item->params->get('access-view') != true && (($item->params->get('show_noauth') != true &&  $user->get('guest') ))) {

            // Redirect to login
           $uri = JFactory::getURI();
           $app->redirect('index.php?option=com_users&view=login&return=' . base64_encode($uri), JText::_('Members please login to view this page. If you are not a member please <a href="/component/users/?view=registration">register here<a>'));
      
           return;
         
      }
How can I override that code and avoid hacking core files?

Re: Visible Menu Item - but need login

Posted: Sat Sep 29, 2012 12:14 am
by zemadeiran
So if the users are already registered they can see the login form?

The only way to do this would be to set and look for a cookie on the users browser.

You can then add the "php if" code to the login components default.php file

Re: Visible Menu Item - but need login

Posted: Sat Sep 29, 2012 12:26 am
by Webdongle

Re: Visible Menu Item - but need login

Posted: Sat Sep 29, 2012 12:33 am
by zemadeiran
I think ihtus does not mind if the link shows up, what he/she seems to need is to identify pre registered users without them being logged in and if so show them the login component.

The only solution I can think of is a cookie to identify registered users.

Re: Visible Menu Item - but need login

Posted: Sat Sep 29, 2012 12:36 am
by Webdongle
Simple just put the menu to Registered and it should auto redirect non logged in users ?

There are also redirects in http://extensions.joomla.org/extensions ... ite-access

Re: Visible Menu Item - but need login

Posted: Sat Sep 29, 2012 12:43 am
by zemadeiran
Or use the kiss principle and not have a login link at all!

Customise the registration email and include a link to the login component...

Re: Visible Menu Item - but need login

Posted: Mon Oct 01, 2012 12:18 pm
by ihtus
to All: thank you for your replies. I appreciate that.

To make everything clear: this is what I need:

1. having a menu item that is linking to an article
2. a user enters (not logged yet) the web site (it does not matter if the user is already registered or not)
3. this user should see the menu item
4. the user clicks on the menu item
5. the user is asked to enter the username/pass
6. after login is ok, the user can see the content of the article where the menu item was linked.

I will read all your postings and will come back. Thank you.

Re: Visible Menu Item - but need login

Posted: Mon Oct 01, 2012 12:26 pm
by ihtus
zemadeiran wrote:I think ihtus does not mind if the link shows up, what he/she seems to need is to identify pre registered users without them being logged in and if so show them the login component.
The only solution I can think of is a cookie to identify registered users.
Sorry for not being explicit. It's not about registered or not, it's about logged in or not. Please see the above post or the first updated post.
Webdongle wrote:Simple just put the menu to Registered and it should auto redirect non logged in users ?
I tried to set menu item ACL to registered => only logged users where able to see the menu item. The users that were not logged yet - didn't see that menu item.
Thanks, but this is not for my case... It's for the case to display the menu item only for not-logged in users (guests).

Re: Visible Menu Item - but need login

Posted: Mon Oct 01, 2012 1:31 pm
by Webdongle
ihtus wrote:... It's for the case to display the menu item only for not-logged in users (guests).
http://docs.joomla.org/Access_Control_L ... nd_Modules shows how to do that.

If you want that menu item to display login then use menu item type Login.

I am having difficulty understanding why a menu item that can not be seen by logged in users points to an Article that can only be accessed by logged in users ?

Re: Visible Menu Item - but need login

Posted: Mon Oct 01, 2012 1:51 pm
by ihtus
Webdongle:
ihtus wrote:... It's for the case to display the menu item only for not-logged in users (guests).
I meant the tutorial you presented is for the case to display the menu item only for not-logged in users (guests).

The thing I need is:
1. having a menu item that is linking to an article
2. a user enters (not logged yet) the web site (it does not matter if the user is already registered or not)
3. this user should see the menu item
4. the user clicks on the menu item
5a. if the user is NOT logged in - the user is asked to enter the username/pass
5b. if the user is logged in -> goto 6
6. after login is ok, the user can see the content of the article where the menu item was linked.

Re: Visible Menu Item - but need login to access

Posted: Mon Oct 01, 2012 6:13 pm
by ihtus
found another solution.
Still looking for a more elegant solution ...

Re: Visible Menu Item - but need login to access

Posted: Mon Oct 01, 2012 6:31 pm
by Webdongle
This plugin displays custom Login to Read More message, when not logged in user visit a article
http://extensions.joomla.org/extensions ... tion/17006

Re: Visible Menu Item - but need login to access

Posted: Mon Oct 01, 2012 6:36 pm
by ihtus
so from your point of view a 3rd party extensions would be a good solution?

Re: Visible Menu Item - but need login to access

Posted: Mon Oct 01, 2012 7:29 pm
by Webdongle
It's my point of view that matters, it's yours. I post that link for you to look at ... if it suits what you need then use it. If it is not 'elegant' enough then don't. With what you want there looks like several work-a-rounds. It's which ever suits you the best.

Re: Visible Menu Item - but need login to access

Posted: Tue Oct 02, 2012 8:34 am
by humvee
[Mod note: Moved from Admin Forum to ACL Forum;]
To help you, in the future, find the correct forum for your topic please read the Which forum to post your question that I have put together.

Re: Visible Menu Item - but need login to access

Posted: Tue Oct 09, 2012 1:13 pm
by ihtus

Re: Visible Menu Item - but need login to access

Posted: Tue Oct 09, 2012 3:13 pm
by Webdongle
Errata
"It's my point of view that matters, it's yours."
should have read
"It's not my point of view that matters, it's yours."

Re: Visible Menu Item - but need login to access

Posted: Mon Dec 02, 2013 9:31 pm
by lotvot
If I understand what you are trying to do by you referring to the content as an article then you could set the access setting on the menu as public to be seen and then set the access setting on your targeted article to registered members, So when registered/logged in members click on the menu they will go straight to the article as registered members while non-logged in/unregistered members are automatically redirected to the sign and/or register page.
I hope the above info may help you if you haven't got this issue resolved.

Good Luck.