- Posts: 26
COMMUNITY FORUM
login required to read more.....
- viswa
-
Topic Author
- Offline
- Junior Member
Less
More
11 years 5 months ago - 11 years 5 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
Thank You... In advance
Please Log in or Create an account to join the conversation.
- viswa
-
Topic Author
- Offline
- Junior Member
Less
More
- Posts: 26
11 years 5 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.
- Lefteris
-
- Offline
- Platinum Member
Less
More
- Posts: 8743
11 years 5 months ago - 11 years 5 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:
and try with this code
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.
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.
Please Log in or Create an account to join the conversation.
- viswa
-
Topic Author
- Offline
- Junior Member
Less
More
- Posts: 26
11 years 5 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
-
- Visitor
11 years 5 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.
- Kashif Kashif
-
- Offline
- New Member
Less
More
- Posts: 3
8 years 11 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 ?
but after login how to redirect back to the same article ?
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
Less
More
- Posts: 15920
8 years 11 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.
You could pass the id of the item on a variable and structure the URL via a plugin and redirect after the login.
Please Log in or Create an account to join the conversation.