Keyword

[SOLVED] Premium Content Items Invisible IF Not Logged In

More
7 years 1 month ago #160822 by Chris Hogan
Replied by Chris Hogan on topic Premium Content Items Invisible IF Not Logged In
ok, so I understand the blocks part, but all of my articles will be mainly for registered users apart from the odd few!

So which blocks are these?

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
7 years 1 month ago #160823 by Krikor Boghossian
Replied by Krikor Boghossian on topic Premium Content Items Invisible IF Not Logged In
Depends on which elements you want to show/ hide.
In the item.php file you can identify each block by the HTML comments.

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

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

More
7 years 1 month ago - 7 years 1 month ago #160829 by Chris Hogan
Replied by Chris Hogan on topic Premium Content Items Invisible IF Not Logged In
Hi, I've tried a quite a few others things since b4 but I've very nearly got it I think...

I have the code below just need to know which bit to change...
		<?php if($this->item->params->get('itemFullText')): ?>
		<!-- Item fulltext -->
		<div class="itemFullText">
			<?php echo $this->item->fulltext; ?>
		</div>
		<?php endif; ?>

		<?php else: ?>
Last edit: 7 years 1 month ago by Chris Hogan.

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
7 years 1 month ago #160849 by Krikor Boghossian
Replied by Krikor Boghossian on topic Premium Content Items Invisible IF Not Logged In
<?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 } ?>

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

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

More
7 years 1 month ago - 7 years 1 month ago #160866 by Chris Hogan
Replied by Chris Hogan on topic Premium Content Items Invisible IF Not Logged In
Thank you for the code...I believe it worked BUT I can only see this line of text ''You must login to see the content etc''...inside a 'public' items fulltext - as a guest!

It also displays the intro text twice (above & below) the login text screenshot . Furthermore it has also made the item registered without myself even changing the access level to be Registered in that particular item!?

However, this in not the main issue - Because on my K2 category page, it still doesn't display my items which are set to the Registered Access level & because of this, there are no items displaying to show guests a bit of sample text with a 'register to read more button...' just like on a normal Joomla setup.

This is basically what I'm trying to replicate.

Thanks again!
Last edit: 7 years 1 month ago by Chris Hogan.

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
7 years 1 month ago #160874 by Krikor Boghossian
Replied by Krikor Boghossian on topic Premium Content Items Invisible IF Not Logged In
This code checks if the user is NOT a public user.
It does not check for any specific groups.
If you need extra functionality take a look at this.
docs.joomla.org/Accessing_the_current_user_object

Now, you can replace the " echo "<p>You must login to see the content. I want your email address.</p>";" part with code that generates a module or simply enter a link.

Now as for the other blocks. The logic is:
Anything that goes inside the else block must be removed from everywhere else.

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

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

More
7 years 1 month ago #160880 by Chris Hogan
Replied by Chris Hogan on topic Premium Content Items Invisible IF Not Logged In
Hi, I've read through the Joomla Doc on 'Accessing the current user object' again & I cannot see what I'm supposed to change to make K2 show public/guest my registered content/items...is it usertype if so does that just go here ($user->guest) instead of the word guest?

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
7 years 1 month ago #160974 by Krikor Boghossian
Replied by Krikor Boghossian on topic Premium Content Items Invisible IF Not Logged In
Look into the "Object Member Variables and Parameters" part.
The groups (Set to the user's group ids.) is what you are looking for.

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

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

More
6 years 11 months ago - 6 years 11 months ago #161656 by Chris Hogan
Replied by Chris Hogan on topic Premium Content Items Invisible IF Not Logged In
Hi There - So I've solved this problem by purchasing an add-on by 'JExtBOX' - called 'Login to Read More'
This has basically given me some other options via a plugin to setup in the best possible way for my site with some free areas some paid...

However, my question is to do with the way users can click an 'image' or the 'title' of an Item to get to the Items Full Text.

Now with the changes I managed so far with the item.php file, I may still be able to implement them in a way for guest users who ''click on an Items Title or Image'' for them to see my 'login message' inside of that item BUT I would need to remove the duplicate text problem I had with this before. Screenshot - goo.gl/2b8neA

Below is the item.php code which displays the login/link message and after that (in the code) is the <!-- Item text -->

Can you advise me about which part I need to look at to remove this duplicate text

<?php $user = JFactory::getUser();
        if ($user->guest) {
                echo '<a href="https://mysite.com/join-now">You must login to see the content!</a>';
        } 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; ?>
Last edit: 6 years 11 months ago by Chris Hogan.

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
6 years 11 months ago #161694 by Krikor Boghossian
Replied by Krikor Boghossian on topic Premium Content Items Invisible IF Not Logged In
Remove the second introtext.

The final code should include the introtext BEFORE the full text.
<?php $user = JFactory::getUser();
    if ($user->guest) {
            echo '<a href="https://mysite.com/join-now">You must login to see the content!</a>';
    } else { ?>
    <?php if($this->item->params->get('itemFullText')): ?>
	<!-- Item fulltext -->
	<div class="itemFullText">
		<?php echo $this->item->fulltext; ?>
	</div>
	<?php endif; ?>
<?php } ?>

As for linking different elements of the template (providing that you use the K2 image) you can add links manually in the category_item.php override.
<a href="<?php echo $this->item->link; ?>">
ELEMENT YOU WANT LINKED
</a>

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