Keyword

limit media access to registered users

  • Sori
  • Sori's Avatar Topic Author
  • Offline
  • Senior Member
More
6 years 1 month ago #166789 by Sori
Hi,
I want to give incentive to my viewers to register on my website. So I want to limit the access of media files to registered users only. How is that possible?

Thanks a lot,
Sohrab
Attachments:

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
6 years 1 month ago #166792 by Krikor Boghossian
Replied by Krikor Boghossian on topic limit media access to registered users
Hello,

You can use Joomla!'s user object in order to alter your template overrides and hide certain parts.
docs.joomla.org/Accessing_the_current_user_object

There are also several examples in this forum on how to hide the fulltext, the same principle applies to all content elements.

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

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

  • Sori
  • Sori's Avatar Topic Author
  • Offline
  • Senior Member
More
6 years 1 month ago #166817 by Sori
Replied by Sori on topic limit media access to registered users
Hello Krikor,

Thanks for your reply. I read that Joomla doc article but still have no clue. I searched this forum for how to limit full article access but couldn't find it, unfortunately. are there any keywords you may suggest?

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

  • Sori
  • Sori's Avatar Topic Author
  • Offline
  • Senior Member
More
6 years 1 month ago - 6 years 1 month ago #166819 by Sori
Replied by Sori on topic limit media access to registered users
I implemented this code in the template but it didn't work. it still shows the video block:
<?php $user = JFactory::getUser(); ?>
		<?php if ($user->guest); ?>{
	<?php echo "<p>You must login to see the content. I want your email address.</p>"; ?>
        } else {
<?php if($this->item->params->get('itemVideo') && !empty($this->item->video)): ?>
	<!-- Item video -->
	<a name="itemVideoAnchor" id="itemVideoAnchor"></a>
	<div class="itemVideoBlock">
		<h3><?php echo JText::_('K2_MEDIA'); ?></h3>

		<?php if($this->item->videoType=='embedded'): ?>
		<div class="itemVideoEmbedded">
			<?php echo $this->item->video; ?>
		</div>
		<?php else: ?>
		<span class="itemVideo"><?php echo $this->item->video; ?></span>
		<?php endif; ?>

		<?php if($this->item->params->get('itemVideoCaption') && !empty($this->item->video_caption)): ?>
		<span class="itemVideoCaption"><?php echo $this->item->video_caption; ?></span>
		<?php endif; ?>

		<?php if($this->item->params->get('itemVideoCredits') && !empty($this->item->video_credits)): ?>
		<span class="itemVideoCredits"><?php echo $this->item->video_credits; ?></span>
		<?php endif; ?>
		<div class="clr"></div>
		}
		?>
	</div>
	<?php endif; ?>

The else statement isn't functional.
Last edit: 6 years 1 month ago by Sori.

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

  • Sori
  • Sori's Avatar Topic Author
  • Offline
  • Senior Member
More
6 years 1 month ago #166820 by Sori
Replied by Sori on topic limit media access to registered users
I solved it.
<?php $user = JFactory::getUser(); ?>
		<?php if($user->guest): ?>
	<?php echo "<p>You must login to see the content. I want your email address.</p>"; ?>
        <?php else: ?>
<?php if($this->item->params->get('itemVideo') && !empty($this->item->video)): ?>
	<!-- Item video -->
	<a name="itemVideoAnchor" id="itemVideoAnchor"></a>
	<div class="itemVideoBlock">
		<h3><?php echo JText::_('K2_MEDIA'); ?></h3>
		<?php if($this->item->videoType=='embedded'): ?>
		<div class="itemVideoEmbedded">
			<?php echo $this->item->video; ?>
		</div>
		<?php else: ?>
		<span class="itemVideo"><?php echo $this->item->video; ?></span>
		<?php endif; ?>

		<?php if($this->item->params->get('itemVideoCaption') && !empty($this->item->video_caption)): ?>
		<span class="itemVideoCaption"><?php echo $this->item->video_caption; ?></span>
		<?php endif; ?>

		<?php if($this->item->params->get('itemVideoCredits') && !empty($this->item->video_credits)): ?>
		<span class="itemVideoCredits"><?php echo $this->item->video_credits; ?></span>
		<?php endif; ?>
		<div class="clr"></div>
		<?php endif; ?>
	</div>
	<?php endif; ?>

:-D :-D

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
6 years 1 month ago #166854 by Krikor Boghossian
Replied by Krikor Boghossian on topic limit media access to registered users
Kudos Sohrab :)

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

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

  • Sori
  • Sori's Avatar Topic Author
  • Offline
  • Senior Member
More
6 years 1 month ago #166865 by Sori
Replied by Sori on topic limit media access to registered users
Thanks,
The problem now is that even for items that don't have a media it shows up.

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
6 years 1 month ago #166880 by Krikor Boghossian
Replied by Krikor Boghossian on topic limit media access to registered users
This check, makes sure that a video exists and it is set to "Show"
<?php if($this->item->params->get('itemVideo') && !empty($this->item->video)): ?>
<?php $user = JFactory::getUser(); ?>
<?php if($user->guest): ?>
// Code for the public
<?php else :?>
	<!-- Item video -->
	<a name="itemVideoAnchor" id="itemVideoAnchor"></a>
	<div class="itemVideoBlock">
		<h3><?php echo JText::_('K2_MEDIA'); ?></h3>
		<?php if($this->item->videoType=='embedded'): ?>
		<div class="itemVideoEmbedded">
			<?php echo $this->item->video; ?>
		</div>
		<?php else: ?>
		<span class="itemVideo"><?php echo $this->item->video; ?></span>
		<?php endif; ?>

		<?php if($this->item->params->get('itemVideoCaption') && !empty($this->item->video_caption)): ?>
		<span class="itemVideoCaption"><?php echo $this->item->video_caption; ?></span>
		<?php endif; ?>

		<?php if($this->item->params->get('itemVideoCredits') && !empty($this->item->video_credits)): ?>
		<span class="itemVideoCredits"><?php echo $this->item->video_credits; ?></span>
		<?php endif; ?>
		<div class="clr"></div>
		<?php endif; ?>
	</div>
<?php endif; ?>
<?php endif; ?>

So you need to refactor a bit
<?php if($this->item->params->get('itemVideo') && !empty($this->item->video)): ?>
...
<?php endif; ?>

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