Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

new.phtml multiple rows and columns for new product display
 
sprachgenerator
Jr. Member
 
Total Posts:  1
Joined:  2008-09-25
 

I am writing to inquire if someone can tell me why I am only getting the first row of here but not the subsequent rows for my new.phtml landing page.

The homepage appears as follows: http://flatline.homeunix.org

In this page - only 4 images appear across - the rest are simply not displayed.

My new.phtml file looks like this:

?>
<?php 
if (($_products $this->getProductCollection()) && $_products->getSize()): ?>
<div class="box recently">
<
h3 class="title"><?php echo $this->__('New Products'?></h3>
<
table cellspacing="5" class="recently-list" id="recently-compared-list-table">
<
tr>
<?php $i=0; foreach ($_products->getItems() as $_product): ?>
    <?php 
if ($i++%4==0): continue; endif; ?>

    
<td>
        <
div>
            <
a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>">
                <
img class="product-image" src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(170, 170) ?>" width="170" height="170" alt="<?php echo $this->htmlEscape($_pro
duct->getName()) ?>"
/>
            </
a>
        </
div>
            <
p><class="product-name" href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>)"><?php echo $this->htmlEscape($_product->getName()) ?></a><
/
p>
            
<?php if($_product->isSaleable()): ?>
                <?php 
else: ?>
            
<div class="out-of-stock"><?php echo $this->__('Out of stock'?></div>
            
<?php endif; ?>
            
<div class="clear"></div>
        </
td>
<?php $i++; endforeach; ?>
<?php 
for($i;$i%8!=0;$i++) ?>
        
<td>&nbsp;</td>
    </
tr>
</
table></div>
<?php endif; ?>

I am pretty much a newbie to magento, php, etc.... So any help on this problem would be greatly appreciated. I’m happy to grant an amazon wishlist item (book, cd, dvd) if someone pitches in to help as I know this is simply the lack of my knowledge at hand.

Thanks!

 
Magento Community Magento Community
Magento Community
Magento Community
 
mk2dev
Member
 
Total Posts:  42
Joined:  2008-08-07
Chicago, IL
 

<?php if ($i++%4==0): continue; endif; ?>

that line is the determining factor. Change it to another number if you want more than 4. I am not sure how it could effect your layout, etc, but that is the line that is stopping you at 4.

i starts at 0… each time through it increments by 1… this is checking is i plus 1 (i++) evenly divided by 4 (IE no remainder)… and continues or ends based on that.

 
Magento Community Magento Community
Magento Community
Magento Community
 
EdY888
Jr. Member
 
Total Posts:  7
Joined:  2008-10-21
 

I’m having a similar problem.  If I want to display all 12 products of my home page (3 rows of 4 products), what do I need to change to achieve this?

 
Magento Community Magento Community
Magento Community
Magento Community
 
true82
Jr. Member
 
Total Posts:  10
Joined:  2008-11-05
 

edit: sorry! please ignore my question.....clearly im new here! LOL!

Hi!

Could I ask what them you started with as a base? Or just the stock default one? I really like your layout and am looking to create something similar!

Any help is appreciated!

 
Magento Community Magento Community
Magento Community
Magento Community
 
joyously
Guru
 
Total Posts:  447
Joined:  2008-08-21
 

See thread: http://www.magentocommerce.com/boards/viewreply/76236/

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top