Hide inactive button associated with custom field

  • Posts: 425
  • Thank you received: 19
7 years 7 months ago #266300

-- HikaShop version -- : 3.0.1

Hi I want to ask how can hide inactive button associated with custom field has no content. The goal is: made button associated with text custom field that will take the user to the official website of the product, but if for example there is no content in the field, the button to hide.

This is the button code

<div class="info-buttons">
  <span class="website">
<?php
    $url = $this->element->website;
	$css_button = $this->config->get('css_button', 'hikabtn');
?>
<a href="<?php echo $url; ?>" class="<?php echo $css_button; ?>" target="_blank" data-toggle="tooltip" data-placement="top" title="Website">
<?php
	echo JText::_('<i class="fa fa-globe" aria-hidden="true"></i>');
?></a>
</span>
</div>

Last edit: 7 years 7 months ago by neo191987.

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

  • Posts: 82683
  • Thank you received: 13337
  • MODERATOR
7 years 7 months ago #266315

Like that:

<?php if(!empty($this->element->website)){ ?>
<div class="info-buttons">
  <span class="website">
<?php
    $url = $this->element->website;
	$css_button = $this->config->get('css_button', 'hikabtn');
?>
<a href="<?php echo $url; ?>" class="<?php echo $css_button; ?>" target="_blank" data-toggle="tooltip" data-placement="top" title="Website">
<?php
	echo JText::_('<i class="fa fa-globe" aria-hidden="true"></i>');
?></a>
</span>
</div>
<?php } ?>

The following user(s) said Thank You: neo191987

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

  • Posts: 425
  • Thank you received: 19
7 years 7 months ago #266326

It works perfectly. Thank you. :)

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

Time to create page: 0.058 seconds
Powered by Kunena Forum