drdecker Posted April 4, 2008 Posted April 4, 2008 Hi I've been looking all over for this answer and just keep going round in circles - so fingers crossed here! Apologies if this is already answered somewhere. How can I display items in the products_new page in multiple columns? Eg, my normal product listing pages have 9 items per page, 3 x 3, this is what I want for my products_new. Currently my products_new page has has 4 items per page, 1 per row. Please help!! Thanks in advance, Grant
drdecker Posted April 7, 2008 Author Posted April 7, 2008 Right, I'm going to answer my own question and hope it helps someone else too :rolleyes: Ok, I used the code at this link Oscommerce cafe products new mod This gives you 2 products per row. If you then refer to the admin panel - Maximum Values / New Products Listing you then set the total for the page. So, if you set this value to 4, with the above code you'll have a display of 2 x 2. But I wanted 3 x 3. Look for the following in the code on the above link: if($i%2==0)echo "<tr> "; Basically this means when 2 products are displayed, a new row is started. So, in the above example that's what gives you 2 x 2 (2 per row, 4 per page). I changed this to if($i%3==0)echo "<tr> "; Then I went to the admin panel and changed the new products max value to 9. So, when the row equals 3 products a new row is started, and with a maximum of 9 per page you get 3 x 3! Simple! I then hacked the new code a bit more as I didn't want all the price, date added etc (that's up to you of course). Here's my page: The RABBIT IN RED Lounge new products
geomilli Posted January 22, 2012 Posted January 22, 2012 No offense to osCommerce Cafe, but that site is too narrow for code. I have cleaned it up and marked it accordingly. The code works perfectly and is easily modified. // This file path for the New Products page is /catalog/products_new.php. To change the display style of this page, alter the following code: <td><table border="0" width="100%" cellspacing="0" cellpadding="2"> <?php if ($products_new_split->number_of_rows > 0) { $products_new_query = tep_db_query($products_new_split->sql_query); while ($products_new = tep_db_fetch_array($products_new_query)) { if ($new_price = tep_get_products_special_price($products_new['products_id'])) { $products_price = '<s>' . $currencies->display_price($products_new['products_price'], tep_get_tax_rate($products_new['products_tax_class_id'])) . '</s> <span class="productSpecialPrice">' . $currencies->display_price($new_price, tep_get_tax_rate($products_new['products_tax_class_id'])) . '</span>'; } else { $products_price = $currencies->display_price($products_new['products_price'], tep_get_tax_rate($products_new['products_tax_class_id'])); } ?> <tr> <td width="<?php echo SMALL_IMAGE_WIDTH + 10; ?>" valign="top" class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products_new['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $products_new['products_image'], $products_new['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>'; ?></td> <td valign="top" class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products_new['products_id']) . '"><b><u>' . $products_new['products_name'] . '</u></b></a><br>' . TEXT_DATE_ADDED . ' ' . tep_date_long($products_new['products_date_added']) . '<br>' . TEXT_MANUFACTURER . ' ' . $products_new['manufacturers_name'] . '<br><br>' . TEXT_PRICE . ' ' . $products_price; ?></td> <td align="right" valign="middle" class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_NEW, tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $products_new['products_id']) . '">' . tep_image_button('button_in_cart.gif', IMAGE_BUTTON_IN_CART) . '</a>'; ?></td> </tr> <tr> <td colspan="3"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> </tr> <?php } } else { ?> // For example, suppose that you want to change the price color and the dimensions of the product display list (two products by two products, with the Add to Cart button appearing below each) (Figure 3.42); the code would need to be changed as follows. // LINE APPROX 88 TO 117 <td><table border="0" width="100%" cellspacing="0" cellpadding="2"><tr> <?php if ($products_new_split->number_of_rows > 0) { $products_new_query = tep_db_query($products_new_split->sql_query); $i=1; while ($products_new = tep_db_fetch_array($products_new_query)) { if ($new_price = tep_get_products_special_price($products_new['products_id'])) { $products_price = '<s>' . $currencies->display_price($products_new['products_price'], tep_get_tax_rate($products_new['products_tax_class_id'])) . '</s> <span class="productSpecialPrice">' . $currencies->display_price($new_price, tep_get_tax_rate($products_new['products_tax_class_id'])) . '</span>'; } else { $products_price = $currencies->display_price($products_new['products_price'], tep_get_tax_rate($products_new['products_tax_class_id'])); } ?> <td><table width="75%" border="0"cellspacing="0" cellpadding="0"> <tr> <!-- Modified New Products page. //--> <td rowspan="4" valign="top" width="<?php echo SMALL_IMAGE_WIDTH + 10; ?>" class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products_new['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $products_new['products_image'], $products_new['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>'; ?></td> <td class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products_new['products_id']) . '"><b><u>' . $products_new['products_name'] . '</u></b></a>';?></td> </tr> <tr> <td class="main"><?=TEXT_DATE_ADDED . ' ' . tep_date_long($products_new['products_date_added'])?></td> </tr> <tr> <td class="main"><?=TEXT_MANUFACTURER . ' ' . $products_new['manufacturers_name']?></td> </tr> <tr> <td class="main"><font color="#FF0000"><?=TEXT_PRICE . ' ' . $products_price?></font></td> </tr> <tr> <td class="main" align="center" colspan="2"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_NEW, tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $products_new['products_id']) . '">' . tep_image_button('button_in_cart.gif', IMAGE_BUTTON_IN_CART) . '</a>'; ?></td> </tr> </table> </td> <?php if($i%2==0)echo "<tr> "; $i++; } ?> <tr> <td colspüan="3"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> </tr> <?php } else { ?>
Recommended Posts
Archived
This topic is now archived and is closed to further replies.