1
votes

I followed this tutorial about ACL - http://community.joomla.org/blogs/community/1252-16-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
    • if the user is NOT logged in - the user is asked to enter the username/pass
    • if the user is logged in -> goto 6
  5. 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

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

// 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?

Or maybe there is a more elegant solution?

Thanks.

1
You could always set the article to "registered" access only so a message appears saying "You do not have access to view this content"Lodder
Lodder: I did this and I got that kind of message, but instead of just that message I need a login form. "EDIT 2" is describing that core hack...but I do not want core hacks...ihtus

1 Answers

1
votes

What you can do is a template override and add the login form to the page that provides the message. A template override will allow you to add extras to pages without hacking the core files, therefore when updating Joomla, it will still be there.

For more information on how to override, please see the link below:

http://docs.joomla.org/How_to_override_the_output_from_the_Joomla!_core

Hope this helps.