Keyword

[SOLVED] how hide value of one extra field from guest?

  • Amin Ebrahimzadeh
  • Amin Ebrahimzadeh's Avatar Topic Author
  • Offline
  • New Member
More
7 years 10 months ago #154889 by Amin Ebrahimzadeh
how hide value of one extra field from guest? was created by Amin Ebrahimzadeh
hi,
I want ,hide one extra fiel value from guests... please help me how change this code:
  <!-- Item extra fields -->
	  <div class="itemExtraFields">
	  	<h3><?php echo JText::_('K2_ADDITIONAL_INFO'); ?></h3>
	  	<ul>
			<?php foreach ($this->item->extra_fields as $key=>$extraField): ?>
			<?php if($extraField->value != ''): ?>
			<li class="<?php echo ($key%2) ? "odd" : "even"; ?> type<?php echo ucfirst($extraField->type); ?> group<?php echo $extraField->group; ?>">
				<?php if($extraField->type == 'header'): ?>
				<h4 class="itemExtraFieldsHeader"><?php echo $extraField->name; ?></h4>
				<?php else: ?>
				<span class="itemExtraFieldsLabel"><?php echo $extraField->name; ?>:</span>
				<span class="itemExtraFieldsValue"><?php echo $extraField->value; ?></span>
				<?php endif; ?>
			</li>
			<?php endif; ?>
			<?php endforeach; ?>
			</ul>
	    <div class="clr"></div>
	  </div>
	  <?php endif; ?>
thnx

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

More
7 years 10 months ago - 7 years 10 months ago #154894 by Javi Mata
Replied by Javi Mata on topic how hide value of one extra field from guest?
hi, with this can load a specified extra field:
$field = $this->item->extraFields->[Alias Field]->value;

i think that can do a override layout and a manual list for extra fields and compare each one with some like this:

$user = JFactory::getUser();
if ($user->guest) {
echo "<p>You must login to see the content</p>";
} else {
echo $this->item->extraFields->[Alias Field]->value;
}

Twitter: @Javi_Mata
Web: www.javimata.com
Last edit: 7 years 10 months ago by Javi Mata.

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


Powered by Kunena Forum