Author Topic: excel table (need to hide header field)  (Read 2299 times)

goldenprizm

  • Beginner
  • *
  • Posts: 12
excel table (need to hide header field)
« on: December 22, 2012, 06:38:41 am »
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>

bytelord

  • Nikos
  • Global Moderator
  • Full Member
  • *
  • Posts: 2369
Re: excel table (need to hide header field)
« Reply #1 on: December 22, 2012, 13:05:17 pm »
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 ...
Production: Joomla 2.5.8 | VM 2.0.14 | PHP 5.3.13
Testing     : Joomla 2.5.8 | VM 2.0.16 | PHP 5.3.8
Testing     : Joomla 2.5.8 |    VM 2.1   | PHP 5.3.8

- Don't Forget to mark thread as solved when it is solved!
- Please do not PM with support questions, use the forum!

goldenprizm

  • Beginner
  • *
  • Posts: 12
Re: excel table (need to hide header field)
« Reply #2 on: December 23, 2012, 04:13:28 am »
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>