Guest Posted October 17, 2006 Posted October 17, 2006 Right now I have 98 products on this page which goes to 10+ pages, I want to limit this to 2 pages anyone have any ideas?
Guest Posted October 17, 2006 Posted October 17, 2006 The code for the page is: <?php /* $Id: products_new.php,v 1.27 2003/06/09 22:35:33 hpdl Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2003 osCommerce Released under the GNU General Public License */ require('includes/application_top.php'); require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_PRODUCTS_NEW); $breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_PRODUCTS_NEW)); ?> <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"> <html <?php echo HTML_PARAMS; ?>> <head> <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>"> <title><?php echo TITLE; ?></title> <base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>"> <link rel="stylesheet" type="text/css" href="stylesheet.css"> </head> <div align="center"> <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0"> <!-- header //--> <?php require(DIR_WS_INCLUDES . 'header.php'); ?> <!-- header_eof //--> <!-- body //--> <table border="0" width="800" cellspacing="0" cellpadding="0"> <tr> <td width="<?php echo BOX_WIDTH; ?>" valign="top" style="padding-left:2px; padding-right:2px;"> <table border="0" width="155" cellspacing="0" cellpadding="0"> <!-- left_navigation //--> <?php require(DIR_WS_INCLUDES . 'column_left.php'); ?> <!-- left_navigation_eof //--> <tr><td><img src="images/spacer.gif" width="1" height="700"></td></tr> </table></td> <!-- body_text //--> <td width="800" valign="top" style="padding-right:4px"> <table border="0" width="100%" cellspacing="0" cellpadding="3"> <tr> <td> <table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td class="pageHeading"><?php echo HEADING_TITLE; ?></td> </tr> </table></td> </tr> <tr> <td height="10"></td> </tr> <?php $products_new_array = array(); $products_new_query_raw = "select p.products_id, pd.products_name, p.products_model, p.products_image, p.products_price, p.products_tax_class_id, p.products_date_added, m.manufacturers_name from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on (p.manufacturers_id = m.manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' order by p.products_date_added DESC, pd.products_name"; $products_new_split = new splitPageResults($products_new_query_raw, MAX_DISPLAY_PRODUCTS_NEW); if (($products_new_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '1') || (PREV_NEXT_BAR_LOCATION == '3'))) { ?> <tr> <td><table border="0" width="100%" cellspacing="0" cellpadding="2"> <tr> <td class="smallText"><?php echo $products_new_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS_NEW); ?></td> <td align="right" class="smallText"><?php echo TEXT_RESULT_PAGE . ' ' . $products_new_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></td> </tr> </table></td> </tr> <tr> <td height="10"></td> </tr> <?php } ?> <tr> <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"><?php echo '<a class="new_products_text" href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products_new['products_id']) . '"><b>' . $products_new['products_name'] . '</b></a><br><span class="new_products_man_text"><b>Sku:</b> ' . $products_new['products_model'] . '</span><br><br>' . '<span class="new_products_price">' . TEXT_PRICE . ' <b>' . $products_price . '</b></span>'; ?></td> <td align="right" valign="middle" class="new_products_price"><?php echo '<a class="new_products_price" 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> <tr> <td colspan="3" height="10"><div align="center"><img src="images/divider_new_products.gif" width="600" height="10"></div></td> </tr> <tr> <td colspan="3"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> </tr> <?php } } else { ?> <tr> <td class="main"><?php echo TEXT_NO_NEW_PRODUCTS; ?></td> </tr> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> </tr> <?php } ?> </table></td> </tr> <?php if (($products_new_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '2') || (PREV_NEXT_BAR_LOCATION == '3'))) { ?> <tr> <td> <table border="0" width="100%" cellspacing="0" cellpadding="2"> <tr> <td class="nextText"><?php echo $products_new_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS_NEW); ?></td> <td align="right" class="nextText"><?php echo TEXT_RESULT_PAGE . '' . $products_new_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></td> </tr> </table> </td> </tr> </table></td> <?php } ?> <td width="1" bgcolor="#ea8624"><img src="images/spacer.gif" width="1" height="1"></td> <td width="3"><img src="images/spacer2.gif" width="2"></td> <!-- body_text_eof //--> </tr> </table> <!-- body_eof //--> <!-- footer //--> <?php require(DIR_WS_INCLUDES . 'footer.php'); ?> <!-- footer_eof //--> <br> </body> </div> </html> <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>
Guest Posted October 17, 2006 Posted October 17, 2006 Anyone know if its possible to limit this to 2 pages?
ComicWisdom Posted October 17, 2006 Posted October 17, 2006 Anyone know if its possible to limit this to 2 pages? I don't know exatly what you mean by limit unless you are thinking of putting 40+ products on the page. If that's what you want, go to admin and set the number of products to display in search results and any other setting you feel appropriate. Just between us, remember there are only 10 kinds of people in the world; those who understand binary and those who don't!! Remember, learning is a "do-it-yourself" experience; although, not necessarily a "do-it-BY-yourself" experience. The quickest way to learn is to forget to BACKUP!
Cathi Posted October 17, 2006 Posted October 17, 2006 Do you mean that you want to show less than 98 products? If so, you can change that through your admin panel. Configuration>>Maximum Values>>New Products Listing If you want to show all 98, but on only 2 pages, then I don't know. Cathi
Guest Posted October 17, 2006 Posted October 17, 2006 I don't know exatly what you mean by limit unless you are thinking of putting 40+ products on the page. If that's what you want, go to admin and set the number of products to display in search results and any other setting you feel appropriate. nope, right now I have added alot of products so they all come up in the products_new page, and their are 10 products on a page so their is like 10 pages. We want it to only have the max of 2 pages instead of 10.
meto Posted October 17, 2006 Posted October 17, 2006 Hello, There is two ways to do this. 1. remove the new products page or code from the index.php (thats what i did) or 2. limit the query responsible for retrieving the newproducts from the database. Ill try to give you more information on how to do this when im back at my own code... But dont wait for me.... explore the code, Trail and error allways gets you somewhere. Perhaps not now but in the future... Patrick
♥Monika in Germany Posted October 18, 2006 Posted October 18, 2006 I suggest modifying the query to this: $prod_array = array();$limited_pages = '2'; $products_query = tep_db_query("select products_id from " . TABLE_PRODUCTS . " where products_status = '1' order by products_date_added DESC limit " . (MAX_DISPLAY_PRODUCTS_NEW * $limited_pages)); while ($products_limited = tep_db_fetch_array($products_query)) { $prod_array[] = $products_limited['products_id']; } $products_new_query_raw = "select p.products_id, pd.products_name, p.products_model, p.products_image, p.products_price, p.products_tax_class_id, p.products_date_added, m.manufacturers_name from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on (p.manufacturers_id = m.manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id in ('" . implode("', '", $prod_array) . "') order by p.products_date_added DESC, pd.products_name"; :-) Monika addicted to writing code ... can't get enough of databases either, LOL! my toolbox: Textpad - Compare and Merge - phpMyAdmin - WS_FTP - Photoshop - How to search the forum Interactive Media Award July 2007 ~ category E-Commerce my advice on the forum is for free, PMs where you send me work are considered consultation which I charge for ...
olsonsp4c Posted November 14, 2006 Posted November 14, 2006 Hello, There is two ways to do this. 1. remove the new products page or code from the index.php (thats what i did) or 2. limit the query responsible for retrieving the newproducts from the database. Ill try to give you more information on how to do this when im back at my own code... But dont wait for me.... explore the code, Trail and error allways gets you somewhere. Perhaps not now but in the future... Patrick I just had the same, issue, here's what to do if you don't want to hack the code. Go to your Administration area --> Configuration --> Max Values (Maximum Values) Custom Product Display, Maximum Pages set to "2" - done Scott Addons I've crafted: osC reCaptcha | Live Support phpOnline | Store Mode | Simple Categories Header | Authorize.Net Infobox Package Tracking Plus | USPS Flat Rate Shipping | USPS Shipping Insurance | RapidSSL Infobox
♥Monika in Germany Posted November 14, 2006 Posted November 14, 2006 I just had the same, issue, here's what to do if you don't want to hack the code. Go to your Administration area --> Configuration --> Max Values (Maximum Values) Custom Product Display, Maximum Pages set to "2" - done Scott interesting :-) but as my default osC doesn't have that option, I believe your code was ... well hacked! :-) Monika addicted to writing code ... can't get enough of databases either, LOL! my toolbox: Textpad - Compare and Merge - phpMyAdmin - WS_FTP - Photoshop - How to search the forum Interactive Media Award July 2007 ~ category E-Commerce my advice on the forum is for free, PMs where you send me work are considered consultation which I charge for ...
olsonsp4c Posted November 14, 2006 Posted November 14, 2006 interesting :-) but as my default osC doesn't have that option, I believe your code was ... well hacked! Sorry about that - I don't know how I got that option! Maybe it was the Advanced Search Mod or the Featured Products Mod - Thanks Monika for pointing that out! Scott Addons I've crafted: osC reCaptcha | Live Support phpOnline | Store Mode | Simple Categories Header | Authorize.Net Infobox Package Tracking Plus | USPS Flat Rate Shipping | USPS Shipping Insurance | RapidSSL Infobox
gray_bale Posted November 15, 2006 Posted November 15, 2006 Anybody got the answer to this one ?? I now have 281 new products. These have been entered over the last 6 months. All I want is to limit the new products to the last, say 6 new items by date order.
♥Monika in Germany Posted November 15, 2006 Posted November 15, 2006 answer to which one ... the question above was answered already, and it should answer your issue also. Use my code and instead of order by products_date_added DESC limit " . (MAX_DISPLAY_PRODUCTS_NEW * $limited_pages)); make it order by products_date_added DESC limit 6"); :-) Monika addicted to writing code ... can't get enough of databases either, LOL! my toolbox: Textpad - Compare and Merge - phpMyAdmin - WS_FTP - Photoshop - How to search the forum Interactive Media Award July 2007 ~ category E-Commerce my advice on the forum is for free, PMs where you send me work are considered consultation which I charge for ...
gray_bale Posted November 15, 2006 Posted November 15, 2006 There must be something fundamental that I am not doing, as I have used other peoples code, and it has no effect. Checkout http://www.gb-online.co.uk/catalog/products_new.php
gray_bale Posted November 16, 2006 Posted November 16, 2006 My humble apols, for some reason I was trying to mod catalog\includes\modules\new_products.php I entered your code round about line 54 of catalog\products_new.php and it works perfectly OK. $prod_array = array(); $limited_pages = '2'; $products_query = tep_db_query("select products_id from " . TABLE_PRODUCTS . " where products_status = '1' order by products_date_added DESC limit 6"); while ($products_limited = tep_db_fetch_array($products_query)) { $prod_array[] = $products_limited['products_id']; } $products_new_query_raw = "select p.products_id, pd.products_name, p.products_model, p.products_image, p.products_price, p.products_tax_class_id, p.products_date_added, m.manufacturers_name from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on (p.manufacturers_id = m.manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id in ('" . implode("', '", $prod_array) . "') order by p.products_date_added DESC, pd.products_name"; $products_new_split = new splitPageResults($products_new_query_raw, MAX_DISPLAY_PRODUCTS_NEW); if (($products_new_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '1') || (PREV_NEXT_BAR_LOCATION == '3'))) { Many thanks.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.