Joomla 2.5
virtuemart 2.0.14
File path: components\com_virtuemart\views\category\tmpl\default.php
I am using the code below for Virtuemart category view. When the <td> field is empty I am left with just the <th> field. Does anyone know how I could hide the <th> field if the <td> field is empty.
Got the original code from:
http://forum.virtuemart.net/index.php?topic=104825.0
<table class="orders">
<tr>
<th>Item#</th>
<th>Kit Type</th>
</tr>
<?php
// Start the Output
foreach ( $this->products as $product ) {
// Show the horizontal seperator
if ($iBrowseCol == 1 && $iBrowseProduct > $BrowseProducts_per_row) { ?>
<div class="horizontal-separator"></div>
<?php }
?>
<td><?php echo JHTML::link($product->link, $product->product_sku); ?></td>
<td><?php echo ($product->kit_type); ?></td>
</table>
Hello,
You could place and if statement for that, in case for example that product_sku is empty?
<table class="orders">
<?php if (!empty($product->product_sku)) {
<tr>
<th>Item#</th>
<th>Kit Type</th>
</tr>
<?php
// Start the Output
foreach ( $this->products as $product ) {
// Show the horizontal seperator
if ($iBrowseCol == 1 && $iBrowseProduct > $BrowseProducts_per_row) { ?>
<div class="horizontal-separator"></div>
<?php }
?>
<td><?php echo JHTML::link($product->link, $product->product_sku); ?></td>
<td><?php echo ($product->kit_type); ?></td>
}?>
</table>
Never tested, please test it ...
I got it... For any one else out there here was the solution that worked for me
<table class="orders">
<tr>
<th><?php if (!empty($product->product_sku)) { ?>header 1 <?php } ?></th>
<th><?php if (!empty($product->kit_type)) { ?>header 2 <?php } ?></th>
<th><?php if (!empty($product->vehicle)) { ?>header 3 <?php } ?></th>
</tr>
<?php
// Start the Output
foreach ( $this->products as $product ) {
// Show the horizontal seperator
if ($iBrowseCol == 1 && $iBrowseProduct > $BrowseProducts_per_row) { ?>
<div class="horizontal-separator"></div>
<?php }
?>
<td><?php echo JHTML::link($product->link, $product->product_sku); ?></td>
<td><?php echo ($product->kit_type); ?></td>
<td><?php echo ($product->vehicle); ?></td>
</tr>
<?php }
} // end of foreach ( $this->products as $product )
?>
</table>