Show joomla article only to registered users or login screen if you are not logged in yes

In Joomla prior to 1.6, I can set a public menu item and its contents: for example, registered for an article .

This leads to a situation where people can see a link to an article in the menu when it is not logged in, but receives a login component whenever it clicks on it. And after that they saw the article.

In 1.7, these same actions lead to a situation where, when you click on a link, the component screen remains blank.

How to get registered articles to display the login screen when the user is not logged in with sufficient rights? It was very easy, and I cannot get it to work.

+5
source share
5 answers

I will answer my question because I’m sure that people will need it in the future, and my solution includes several rules of additional code, and then you can install each article, etc. .... Registered, and you will see a field login when the user is not logged in.

In your index.php templates, put this at the top, it gets the level of access to your article.

$article =& JTable::getInstance("content");
$article->load(JRequest::getVar('id'));
$cAccLevel = $article->get("access");

Then add the module position above the component and show it only when your required access level> 1

<?php if($cAccLevel > 1): ?>
    <jdoc:include type="modules" name="LOGIN_MODULE_POSITION" />
<?php endif; ?>

Then add the registration module in the module manager to LOGIN_MODULE_POSITION.

Voila ... there is no need for routing, etc .... everything works out of the box, I chose the style for the exit window and action field as follows:

.logout-button,
.actions{
    display:none;
}

Good luck

+9
  • , , "   ".
  • ,   .
  • ( "" , "" ).    " ". ,    .
  • "" (, " " ) , (, "   " ). "".    " " " "    " ".    "Public", , .

  • "mod_mainmenu" ,    .

  • "". , "Public" .

, ( ) "       Article", "        ". ,        ( " " ).        , .

+5

, , :

$user =& JFactory::getUser();

    <?php
   if( !$user->guest ){ ?>

       [[what ever you want to do ]]
   <?php endif; ?> 

, !

+2

CONTENT, , .

:

3 :

,

:

.

+1
source

First of all, you need to upgrade your joomla installation to version 2.5 (this is the latest version of joomla), 1.7 is no longer supported by the Joomla community.

There are several ways to set viewing rights. K2 is a useful CCK component for doing this work, and a useful technique that I use is to “link” your article categories to a menu and set specific permissions for menu items

-2
source

All Articles