News:

Support the VirtueMart project and become a member

Main Menu

Problem with closing a row (coding)

Started by belsaas, June 07, 2014, 11:22:09 AM

Previous topic - Next topic

belsaas

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]
-------------------------------
Joomla 3.8.1
Virtuemart 3.2.4
PHP 7.1
-------------------------------

GJC Web Design

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 ?>

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

belsaas

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?
-------------------------------
Joomla 3.8.1
Virtuemart 3.2.4
PHP 7.1
-------------------------------

GJC Web Design

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

benek

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

 } 
?>