News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

excel table (need to hide header field)

Started by goldenprizm, December 22, 2012, 06:38:41 AM

Previous topic - Next topic

goldenprizm

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

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

#2
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>