Keyword

login required to read more.....

  • viswa
  • viswa's Avatar Topic Author
  • Offline
  • Junior Member
More
10 years 10 months ago - 10 years 10 months ago #120731 by viswa
login required to read more..... was created by viswa
i want to restrict specific user group to some data only, if he clicks on read more link of data then it should ask for the login details of the user. i am using 2.6.7 K2 and 3.0 Joomla plz suggest me how to do it its very urgent for me ..

Thank You... In advance

Please Log in or Create an account to join the conversation.

  • viswa
  • viswa's Avatar Topic Author
  • Offline
  • Junior Member
More
10 years 10 months ago #120732 by viswa
Replied by viswa on topic Re: login required to read more.....
Plz help me in this topic its very urgent

Please Log in or Create an account to join the conversation.

More
10 years 10 months ago - 10 years 10 months ago #120733 by Lefteris
Replied by Lefteris on topic Re: login required to read more.....
You will have to make a certain modification to the category_item.php of your override (templates/your_template/html/com_k2/default/category_item.php).
Locate the point where the read more block is set up
The code should be:
<?php if ($this->item->params->get('catItemReadMore')): ?>         
        <!-- Item "read more..." link -->
        <div class="catItemReadMore">
                <a class="k2ReadMore" href="<?php echo $this->item->link; ?>">
                        <?php echo JText::_('K2_READ_MORE'); ?>
                </a>
        </div>

and try with this code
<?php if ($this->item->params->get('catItemReadMore') && in_array('USER_GROUP_ID', JFactory::getUser()->get('groups'))): ?>     
        <!-- Item "read more..." link -->
        <div class="catItemReadMore">
                <a class="k2ReadMore" href="<?php echo $this->item->link; ?>">
                        <?php echo JText::_('K2_READ_MORE'); ?>
                </a>
        </div>
        <?php else: ?>
         <!-- Item "read more..." link -->
  <div class="catItemReadMore">
    <a class="k2ReadMore" href="YOUR_LOGIN_LINK">
      <?php echo JText::_('K2_READ_MORE'); ?>
    </a>
  </div> 
        <?php endif; ?>

The in_array('USER_GROUP_ID', JFactory::getUser()->get('groups')) checks if the usergroup is the one permitted and then the readmore link will show. Otherwise it won't.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

  • viswa
  • viswa's Avatar Topic Author
  • Offline
  • Junior Member
More
10 years 10 months ago #120734 by viswa
Replied by viswa on topic Re: login required to read more.....
Thank You it worked if i want to give the permission for two or more user groups then how can i add two user group ids now i have added only one id.

Please Log in or Create an account to join the conversation.

  • Yiota
  • Yiota's Avatar
  • Visitor
10 years 10 months ago #120735 by Yiota
Replied by Yiota on topic Re: login required to read more.....
Then try changing your if statement like
<?php if ($this->item->params->get('catItemReadMore') && (in_array('USER_GROUP_ID', JFactory::getUser()->get('groups')) || in_array('USER_GROUP_ID2', JFactory::getUser()->get('groups')) || in_array('USER_GROUP_ID3', JFactory::getUser()->get('groups')))): ?>   

Please Log in or Create an account to join the conversation.

More
8 years 4 months ago #154670 by Kashif Kashif
Replied by Kashif Kashif on topic login required to read more.....
Hello, thanks the code is working just fine...

but after login how to redirect back to the same article ?

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 4 months ago #154679 by Krikor Boghossian
Replied by Krikor Boghossian on topic login required to read more.....
That requires custom coding.
You could pass the id of the item on a variable and structure the URL via a plugin and redirect after the login.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum