VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: belsaas on June 07, 2014, 11:22:09 AM

Title: Problem with closing a row (coding)
Post by: belsaas on June 07, 2014, 11:22:09 AM
Hi! I have made an override of the category page default.php.
It works good but I have some problem with the closing tag or code. (See the attached picture of the page)

I need to close the row, I think, and I have tried different solutions without good results.
Can some help me to solve this problem.

The code I use are this one:

<!-- ***** HER STARTER RADEN MED PRODUKTER  ******-->
    <div class="row">
   <?php }
      
      // Show Products ?>
      <div class="product">
         <div class="spacer">
               
                <!-- START OF DENNE VISER BILDE OG PRODUKTDETALJEKNAPP-->
                <div class="width13 floatleft center">
               <div>
                  <?php /** @todo make image popup */
                     echo $product->images[0]->displayMediaThumb('class="browseProductImage" border="0" title="'.$product->product_name.'" ',true,'class="modal"');
                  ?>
                      </div>
                    <div style="padding-top:8px">
                       <?php // Product Details Button
                     echo JHTML::link($product->link, JText::_('COM_VIRTUEMART_PRODUCT_DETAILS'), array('title' => $product->product_name,'class' => 'product-details'));
                  ?>
                     </div>
            </div>
                <!-- END OF DENNE VISER BILDE OG PRODUKTDETALJEKNAPP-->
               
                <!-- START OF DENNE VISER TITTEL OG COSTUMS FIELDS -->
            <div style="padding-left:10px" class="width27 floatleft">
               <div class="category-header"><?php echo JHTML::link($product->link, $product->product_name); ?></div>
                    <div>
                  <?php
                  foreach($product->customfields as $field) {   
                  ?>
                        <div class="customfields">
                           <span class="vm-custom-title"><?php echo JText::_($field->custom_title); ?></span>
                           <span class="vm-display"><?php echo $field->display ?></span>
                       </div>
                        <?php
                   $custom_title = $field->custom_title;
                   }
                   ?>
                   </div>
                </div>
                <!-- END OF DENNE VISER TITTEL OG COSTUMS FIELDS -->
              
                <!-- DENNE STARTER ADDTOCART DELEN AV RADEN -->
                <div class="width50 floatright">
              <?php include 'addToCartCategory.php'; ?>
                </div>      
              <!-- END OF DENNE STARTER ADDTOCART DELEN AV RADEN -->
               
         </div><!-- end of spacer -->
      </div> <!-- end of product -->
      
      <?php // Do we need to close the current row now?
            if ($iBrowseCol == $BrowseProducts_per_row || $iBrowseProduct == $BrowseTotalProducts) {?>
         <div class="clear"></div>
 
  </div> <!-- end of row -->
  <div class="clear"></div>   
    
     <?php
      $iBrowseCol = 1;
         } else {
         $iBrowseCol ++;
         }
         $iBrowseProduct ++;
      }    
      // end of foreach ( $this->products as $product )
      // Do we need a final closing row tag?
      if ($iBrowseCol != 1) { ?>
<div class="clear"></div>

<?php
}
?>





-------------------------------
Joomla 2.5.20
Virtuemart 2.6.6
-------------------------------

[attachment cleanup by admin]
Title: Re: Problem with closing a row (coding)
Post by: GJC Web Design on June 07, 2014, 11:42:06 AM
as you only want 1 product per row you don't need any closing row logic..

just use

<!-- ***** HER STARTER RADEN MED PRODUKTER  ******-->
<?php foreach ( $this->products as $product ) { ?>
    <div class="row">
      <div class="product">
         <div class="spacer">
               
                <!-- START OF DENNE VISER BILDE OG PRODUKTDETALJEKNAPP-->
                <div class="width13 floatleft center">
               <div>
                  <?php /** @todo make image popup */
                     
echo $product->images[0]->displayMediaThumb('class="browseProductImage" border="0" title="'.$product->product_name.'" ',true,'class="modal"');
                  
?>

                      </div>
                    <div style="padding-top:8px">
                       <?php // Product Details Button
                     
echo JHTML::link($product->linkJText::_('COM_VIRTUEMART_PRODUCT_DETAILS'), array('title' => $product->product_name,'class' => 'product-details'));
                  
?>

                     </div>
            </div>
                <!-- END OF DENNE VISER BILDE OG PRODUKTDETALJEKNAPP-->
               
                <!-- START OF DENNE VISER TITTEL OG COSTUMS FIELDS -->
            <div style="padding-left:10px" class="width27 floatleft">
               <div class="category-header"><?php echo JHTML::link($product->link$product->product_name); ?></div>
                    <div>
                  <?php
                  
foreach($product->customfields as $field) {   
                  
?>

                        <div class="customfields">
                           <span class="vm-custom-title"><?php echo JText::_($field->custom_title); ?></span>
                           <span class="vm-display"><?php echo $field->display ?></span>
                       </div>
                        <?php
                   $custom_title 
$field->custom_title;
                   }
                   
?>

                   </div>
                </div>
                <!-- END OF DENNE VISER TITTEL OG COSTUMS FIELDS -->
             
                <!-- DENNE STARTER ADDTOCART DELEN AV RADEN -->
                <div class="width50 floatright">
              <?php include 'addToCartCategory.php'?>
                </div>     
              <!-- END OF DENNE STARTER ADDTOCART DELEN AV RADEN -->
               
         </div><!-- end of spacer -->
      </div> <!-- end of product -->
     
     
     

  </div> <!-- end of row -->
  <div class="clear"></div>   
  <?php ?>

Title: Re: Problem with closing a row (coding)
Post by: belsaas on June 07, 2014, 17:17:24 PM
Thanx for the answer, but the code make the page total black.  ::)
The close tag are default from the default.php, so why do you mean those shall be deleted?
Title: Re: Problem with closing a row (coding)
Post by: GJC Web Design on June 08, 2014, 00:00:47 AM
haven't tested - just quickly editted - turn on your reporting to find the syntax error  (don't see one at a glance)
but the point is if you have 1 product per row  you don't need any "do I need to close this row" logic
Title: Re: Problem with closing a row (coding)
Post by: benek on July 10, 2014, 19:05:27 PM
I think that there is a bug in categories.php.

It is not about closing current row of subcategories in one line, but there is no closing div for all rows.

In 2.9.8 end of categories looks like:

// Do we need a final closing row tag?
if ($iCol != 1) { ?>
<div class="clear"></div>
</div>
<?php
}
 } 
?>


in version 2.0 ending looked like:

// Do we need a final closing row tag?
if ($iBrowse != 1) {
echo "<div class='clear'></div></div>";
}
?>
<div class="clear"></div>
</div>
<?php ?>


I corrected issue with this code:
// Do we need a final closing row tag?
if ($iCol != 1) {
echo '<div class="clear"></div>
</div>';
}
?>
<div class="clear"></div>
</div>

<?php

 } 
?>