News:

Support the VirtueMart project and become a member

Main Menu

Hide tab when customfield is empty

Started by alexanderflr, September 07, 2017, 12:02:22 PM

Previous topic - Next topic

alexanderflr

Hi,
I have a custom field in a tab that I would like to hide  when custom field is empty. Any ideas?
My actual code for tabs is:


<div id="tab-block" class="tab-block">
<ul class="nav nav-pills" id="ShopTab">
<?php if (!empty($this->product->product_desc)) {?>
<li class="tab_des active">
<a data-toggle="tab" href="#Shop-description"><?php echo JText::_('Shop_JSHOP_FULL_DESCRIPTION'); ?></a>
</li>
<?php }?>
<li class="tab_des">
<a data-toggle="tab" href="#Shop-ingredients"><?php echo JText::_('INGREDIENTS'); ?></a>
</li>

            <li class="tab_des">
<a data-toggle="tab" href="#Shop-allergens"><?php echo JText::_('ALLERGENS'); ?></a>
</li>

<li class="tab_des">
<a data-toggle="tab" href="#Shop-nutrition"><?php echo JText::_('NUTRITIONAL INFORMATION'); ?></a>
</li>      
<li class="tab_review last"><a data-toggle="tab" href="#Shop-reviews"><?php echo JText::_('REVIEWS'); ?></a></li>
</ul>
<div id="ShopTabContent" class="tab-content">
<?php // Product Description
if (!empty($this->product->product_desc)) { ?>

<div id="Shop-description" class="tab-pane fade in product-description active">
<?php /** @todo Test if content plugins modify the product description */ ?>
<span class="title"><?php echo vmText::_(''?></span>
<?php echo $this->product->product_desc?>
</div>
<?php // Product Description END ?>

            <div id="Shop-allergens" class="tab-pane">
<?php echo shopFunctionsF::renderVmSubLayout('customfields', array('product'=>$this->product'position'=>'tabcustom1'));
?>
</div>

            <div id="Shop-ingredients" class="tab-pane">
<?php
echo shopFunctionsF::renderVmSubLayout('customfields', array('product'=>$this->product'position'=>'tabcustom2'));
?>
</div>
<div id="Shop-nutrition" class="tab-pane">

</div>
<div id="Shop-reviews" class="tab-pane fade product-review">
<?php
echo $this->loadTemplate('reviews');
?>

</div>
</div>
</div>
<?php


I'm using Joomla! 3.7.5 Stable, PHP 7.0.18, Virtuemart 3.2.2
Thank you very much!
VM 3.2.8, Joomla 3.8.3, PHP 7.0.26

Ghost

Try this:

if(!empty($this->product->customfieldsSorted['tabcustom1'])){...

alexanderflr

Hi,

I tried, and is completely hiding from everywhere even if the field is not empty  :'(
VM 3.2.8, Joomla 3.8.3, PHP 7.0.26

GJC Web Design

@ghosts code should work

surround each <li>  then each div with the appro. if statement
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

alexanderflr

Hi,

Tried again, and is working now  8). Thank you very much Ghost and GJC Web Design. I appreciate your help.

Have a good weekend!
VM 3.2.8, Joomla 3.8.3, PHP 7.0.26