- Posts: 11
COMMUNITY FORUM
- Forum
- K2 Community Forum
- English K2 Community
- how to make item viewing require login but category public?
how to make item viewing require login but category public?
- rustyDusty
- Topic Author
- Offline
- New Member
Less
More
7 years 6 months ago - 7 years 6 months ago #160852
by rustyDusty
how to make item viewing require login but category public? was created by rustyDusty
I need visitors to be able to see items on the category page but upon clicking they are told they have to login.
I set my category access to public and I set my items in category to registered. Now my category page loads but I don't see any items unless I'm logged in.
I created a sub-template and set my category to this sub-template but I am lost as to how to set up this feature so that item images and intro texts are visible to the public on category page but can only be fully viewed to registered members.
Thank you.
I set my category access to public and I set my items in category to registered. Now my category page loads but I don't see any items unless I'm logged in.
I created a sub-template and set my category to this sub-template but I am lost as to how to set up this feature so that item images and intro texts are visible to the public on category page but can only be fully viewed to registered members.
Thank you.
Last edit: 7 years 6 months ago by rustyDusty.
Please Log in or Create an account to join the conversation.
- rustyDusty
- Topic Author
- Offline
- New Member
Less
More
- Posts: 11
7 years 6 months ago - 7 years 6 months ago #160856
by rustyDusty
Replied by rustyDusty on topic how to make item viewing require login but category public?
I searched in my sub-template file item.php for this line:
I added this code on top of that line:
underneathI added this code:
so that the whole thing looks like this:
I set my items to guest access but they were still not visible in the category page. So I set them to public and while they were visible clicking on an item resulted in this error message:
So I removed the:line on 250.
Now the code looks like this:
I have included some of the preceding code and aft code so you can see how they flow into each other now.
I get no error message.
The problem is this code does not work.
When I set the items of the category to guest access I still can't see them on the category page.
How can I get the items to display in category yet demand that user login when they click the item to view full text.
Thank you
<?php if($this->item->params->get('itemFullText')): ?>
I added this code on top of that line:
<?php $user = JFactory::getUser();
if ($user->guest) {
echo "<p>You must login to see the content. I want your email address.</p>";
} else { ?>
underneath
<?php endif; ?>
<?php else: ?>
<?php } ?>
so that the whole thing looks like this:
<?php $user = JFactory::getUser();
if ($user->guest) {
echo "<p>You must login to see the content. I want your email address.</p>";
} else { ?>
<?php if($this->item->params->get('itemFullText')): ?>
<!-- Item fulltext -->
<div class="itemFullText">
<?php echo $this->item->fulltext; ?>
</div>
<?php endif; ?>
<?php else: ?>
<?php } ?>
I set my items to guest access but they were still not visible in the category page. So I set them to public and while they were visible clicking on an item resulted in this error message:
Parse error: syntax error, unexpected 'else' (T_ELSE) in /home/myAccount/public_html/ns/templates/purity_iii/html/com_k2/members/item.php on line 250
So I removed the:
<?php else: ?>
Now the code looks like this:
<!-- Item introtext -->
<div class="itemIntroText">
<?php echo $this->item->introtext; ?>
</div>
<?php endif; ?>
<?php $user = JFactory::getUser();
if ($user->guest) {
echo "<p>You must login to see the content. I want your email address.</p>";
} else { ?>
<?php if($this->item->params->get('itemFullText')): ?>
<!-- Item fulltext -->
<div class="itemFullText">
<?php echo $this->item->fulltext; ?>
</div>
<?php endif; ?>
<?php } ?>
<!-- Item text -->
<div class="itemFullText">
<?php echo $this->item->introtext; ?>
</div>
<?php endif; ?>
<div class="clr"></div>
<?php if($this->item->params->get('itemExtraFields') && count($this->item->extra_fields)): ?>
<!-- Item extra fields -->
I have included some of the preceding code and aft code so you can see how they flow into each other now.
I get no error message.
The problem is this code does not work.
When I set the items of the category to guest access I still can't see them on the category page.
How can I get the items to display in category yet demand that user login when they click the item to view full text.
Thank you
Last edit: 7 years 6 months ago by rustyDusty.
Please Log in or Create an account to join the conversation.
- rustyDusty
- Topic Author
- Offline
- New Member
Less
More
- Posts: 11
7 years 6 months ago #160857
by rustyDusty
Replied by rustyDusty on topic how to make item viewing require login but category public?
Actually I was wrong about there being no error. When I login to view items the page loads without error message but unfortunately the written text in the article becomes invisible. The item image is there but NO TEXT!!??? So I just copied the item.php file from default to my sub-template folder to correct this problem.
This situation is NOT working out! Too frustrating!
Is there a way to make a request so that future k2 versions include the option of making items visible to the public in their category page yet restrict actual articles to registered members?
Thank you (pulling hair out!!!)
This situation is NOT working out! Too frustrating!
Is there a way to make a request so that future k2 versions include the option of making items visible to the public in their category page yet restrict actual articles to registered members?
Thank you (pulling hair out!!!)
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
- Offline
- Platinum Member
Less
More
- Posts: 15920
7 years 6 months ago #160873
by Krikor Boghossian
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by Krikor Boghossian on topic how to make item viewing require login but category public?
You have broken code.
As I have already mentioned, this requires basic coding skills.
I have provided examples but if you do not know how to properly open and close if/else statements I recommend contacting a developer.
As I have already mentioned, this requires basic coding skills.
I have provided examples but if you do not know how to properly open and close if/else statements I recommend contacting a developer.
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- rustyDusty
- Topic Author
- Offline
- New Member
Less
More
- Posts: 11
7 years 6 months ago - 7 years 6 months ago #160881
by rustyDusty
Well that was useful and supportive.
Replied by rustyDusty on topic how to make item viewing require login but category public?
As I have already mentioned, this requires basic coding skills.
Well that was useful and supportive.
Last edit: 7 years 6 months ago by rustyDusty. Reason: Because sometimes you have to spell it out.
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
- Offline
- Platinum Member
Less
More
- Posts: 15920
7 years 6 months ago #160991
by Krikor Boghossian
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by Krikor Boghossian on topic how to make item viewing require login but category public?
There are several threads within the same page which provide complete instructions and code.
We are here to assist users not build entire sites.
As I have already mentioned there are unclosed elements.
We are here to assist users not build entire sites.
As I have already mentioned there are unclosed elements.
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- Forum
- K2 Community Forum
- English K2 Community
- how to make item viewing require login but category public?