Visible Menu Item - but need login to access

Moderators: mandville, PhilD, General Support Moderators

Locked
ihtus
Joomla! Intern
Joomla! Intern
Posts: 66
Joined: Thu Feb 28, 2008 2:30 pm
Location: Canada

Visible Menu Item - but need login to access

Post by ihtus » Fri Sep 28, 2012 8:28 pm

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?
Last edited by ihtus on Mon Oct 01, 2012 2:43 pm, edited 5 times in total.

User avatar
zemadeiran
Joomla! Guru
Joomla! Guru
Posts: 933
Joined: Wed Oct 25, 2006 2:46 pm
Contact:

Re: Visible Menu Item - but need login

Post by zemadeiran » Sat Sep 29, 2012 12:14 am

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

User avatar
Webdongle
Joomla! Master
Joomla! Master
Posts: 37159
Joined: Sat Apr 05, 2008 9:58 pm

Re: Visible Menu Item - but need login

Post by Webdongle » Sat Sep 29, 2012 12:26 am

http://www.weblinksonline.co.uk/
https://www.weblinksonline.co.uk/updating-joomla.html
"The definition of insanity is doing the same thing over and over again, but expecting different results": Albert Einstein

User avatar
zemadeiran
Joomla! Guru
Joomla! Guru
Posts: 933
Joined: Wed Oct 25, 2006 2:46 pm
Contact:

Re: Visible Menu Item - but need login

Post by zemadeiran » Sat Sep 29, 2012 12:33 am

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.

User avatar
Webdongle
Joomla! Master
Joomla! Master
Posts: 37159
Joined: Sat Apr 05, 2008 9:58 pm

Re: Visible Menu Item - but need login

Post by Webdongle » Sat Sep 29, 2012 12:36 am

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
http://www.weblinksonline.co.uk/
https://www.weblinksonline.co.uk/updating-joomla.html
"The definition of insanity is doing the same thing over and over again, but expecting different results": Albert Einstein

User avatar
zemadeiran
Joomla! Guru
Joomla! Guru
Posts: 933
Joined: Wed Oct 25, 2006 2:46 pm
Contact:

Re: Visible Menu Item - but need login

Post by zemadeiran » Sat Sep 29, 2012 12:43 am

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...

ihtus
Joomla! Intern
Joomla! Intern
Posts: 66
Joined: Thu Feb 28, 2008 2:30 pm
Location: Canada

Re: Visible Menu Item - but need login

Post by ihtus » Mon Oct 01, 2012 12:18 pm

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.

ihtus
Joomla! Intern
Joomla! Intern
Posts: 66
Joined: Thu Feb 28, 2008 2:30 pm
Location: Canada

Re: Visible Menu Item - but need login

Post by ihtus » Mon Oct 01, 2012 12:26 pm

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).

User avatar
Webdongle
Joomla! Master
Joomla! Master
Posts: 37159
Joined: Sat Apr 05, 2008 9:58 pm

Re: Visible Menu Item - but need login

Post by Webdongle » Mon Oct 01, 2012 1:31 pm

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 ?
http://www.weblinksonline.co.uk/
https://www.weblinksonline.co.uk/updating-joomla.html
"The definition of insanity is doing the same thing over and over again, but expecting different results": Albert Einstein

ihtus
Joomla! Intern
Joomla! Intern
Posts: 66
Joined: Thu Feb 28, 2008 2:30 pm
Location: Canada

Re: Visible Menu Item - but need login

Post by ihtus » Mon Oct 01, 2012 1:51 pm

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.

ihtus
Joomla! Intern
Joomla! Intern
Posts: 66
Joined: Thu Feb 28, 2008 2:30 pm
Location: Canada

Re: Visible Menu Item - but need login to access

Post by ihtus » Mon Oct 01, 2012 6:13 pm

found another solution.
Still looking for a more elegant solution ...

User avatar
Webdongle
Joomla! Master
Joomla! Master
Posts: 37159
Joined: Sat Apr 05, 2008 9:58 pm

Re: Visible Menu Item - but need login to access

Post by Webdongle » Mon Oct 01, 2012 6:31 pm

This plugin displays custom Login to Read More message, when not logged in user visit a article
http://extensions.joomla.org/extensions ... tion/17006
http://www.weblinksonline.co.uk/
https://www.weblinksonline.co.uk/updating-joomla.html
"The definition of insanity is doing the same thing over and over again, but expecting different results": Albert Einstein

ihtus
Joomla! Intern
Joomla! Intern
Posts: 66
Joined: Thu Feb 28, 2008 2:30 pm
Location: Canada

Re: Visible Menu Item - but need login to access

Post by ihtus » Mon Oct 01, 2012 6:36 pm

so from your point of view a 3rd party extensions would be a good solution?

User avatar
Webdongle
Joomla! Master
Joomla! Master
Posts: 37159
Joined: Sat Apr 05, 2008 9:58 pm

Re: Visible Menu Item - but need login to access

Post by Webdongle » Mon Oct 01, 2012 7:29 pm

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.
http://www.weblinksonline.co.uk/
https://www.weblinksonline.co.uk/updating-joomla.html
"The definition of insanity is doing the same thing over and over again, but expecting different results": Albert Einstein

User avatar
humvee
Joomla! Master
Joomla! Master
Posts: 14713
Joined: Wed Aug 17, 2005 10:27 pm
Location: Kent, England

Re: Visible Menu Item - but need login to access

Post by humvee » Tue Oct 02, 2012 8:34 am

[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.

ihtus
Joomla! Intern
Joomla! Intern
Posts: 66
Joined: Thu Feb 28, 2008 2:30 pm
Location: Canada

Re: Visible Menu Item - but need login to access

Post by ihtus » Tue Oct 09, 2012 1:13 pm


User avatar
Webdongle
Joomla! Master
Joomla! Master
Posts: 37159
Joined: Sat Apr 05, 2008 9:58 pm

Re: Visible Menu Item - but need login to access

Post by Webdongle » Tue Oct 09, 2012 3:13 pm

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."
http://www.weblinksonline.co.uk/
https://www.weblinksonline.co.uk/updating-joomla.html
"The definition of insanity is doing the same thing over and over again, but expecting different results": Albert Einstein

lotvot
Joomla! Apprentice
Joomla! Apprentice
Posts: 21
Joined: Fri Dec 08, 2006 8:18 am

Re: Visible Menu Item - but need login to access

Post by lotvot » Mon Dec 02, 2013 9:31 pm

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.


Locked

Return to “Access Control List (ACL) in Joomla! 2.5”