Click here to Skip to main content
15,891,529 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,
I have a latest product page in my opencart, but i need create more product in one line. Now in one line are three products, i need that there will be for.
There is my code:

<
XML
<script type="text/javascript">
        (function($){$.fn.equalHeights=function(minHeight,maxHeight){tallest=(minHeight)?minHeight:0;this.each(function(){if($(this).height()>tallest){tallest=$(this).height()}});if((maxHeight)&&tallest>maxHeight)tallest=maxHeight;return this.each(function(){$(this).height(tallest)})}})(jQuery)
    $(window).load(function(){
        if($(".maxheight-feat").length){
        $(".maxheight-feat").equalHeights()}
    })
</script>
<div class="wrapper"></div>
<div class="box featured">
  <div class="box-heading"><?php echo $heading_title; ?></div>
      <div class="box-content">

        <div class="box-product">
            <ul>
                <?php $i=0; ?>
              <?php foreach ($products as $product) { $i++; ?>
              <?php
                        if ($i%3==1) {
                            $a='class="first-in-line"';
                        }
                        elseif ($i%3==0) {
                            $a='class="last-in-line"';
                        }
                        else {
                            $a='';
                        }
                    ?>
              <li  <?php echo $a?>>
                <div class="inner-indent">
                     <?php if ($product['thumb']) { ?>
                    <div class="image2"><a href="<?php echo $product['href']; ?>"><img src="<?php echo $product['thumb']; ?>" alt="<?php echo $product['name']; ?>" /></a></div>
                    <?php } ?>
                    <div class="rating">

                    </div>
                    <div class="name maxheight-feat"><a href="<?php echo $product['href']; ?>"><?php echo $product['name']; ?></a></div>


                    <?php ?>

                    <div class="wrapper">

                        <?php if ($product['special']) { ?>
                        <div class="price">
                          <?php echo $product['special']; ?>
                        </div>
                        <?php } else  {?>
                            <div class="price">
                              <?php echo $product['price']; ?>
                            </div>
                        <?php }?>

                    </div>
                    <div class="cart">
                        <a data-id="<?php echo $product['product_id']; ?>;" class="button addToCart"><span><?php echo $button_cart; ?></span></a>
                        <div class="extra-button">

                        </div>
                        <div class="clear"></div>
                    </div>
                </div>
              </li>
              <?php } ?>
          </ul>
        </div>
  </div>
</div>
Posted

1 solution

I think you need to change this part. Where the i modulo 3 trick sits.
PHP
if ($i%3==1) {
    $a='class="first-in-line"';
}
elseif ($i%3==0) {
    $a='class="last-in-line"';
}
else {
    $a='';
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900