Guest Posted July 18, 2004 Posted July 18, 2004 hello there again!!! this is my second posting to this wonderful community. i hate to ask another question but i've come to a stumbling block. it pertains to the randomness of the new products in the main module and category screens. i loaded up the first original file from allen fox then the revised oe by lawrence maynard (http://www.oscommerce.com/community/contributions,1849/page,6). here is my site for reference: http://newmexicanconnection.com/shop and my shop/includes/modules/new_products.php file as follows: <?php /* $Id: new_products.php,v 1.35 2004/02/05 15:50:00 adf Exp $ Randomize New Products $Id: new_products.php,v 1.34 2003/06/09 22:49:58 hpdl Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright © 2003 osCommerce Released under the GNU General Public License */ ?> <!-- new_products //--> <?php $info_box_contents = array(); $info_box_contents[] = array('text' => sprintf(TABLE_HEADING_NEW_PRODUCTS, strftime('%B'))); new contentBoxHeading($info_box_contents); if ( (!isset($new_products_category_id)) || ($new_products_category_id == '0') ) { // start random new products $new_products_query = tep_db_query("select p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where products_status = '1' order by p.products_date_added desc limit " . MAX_RANDOM_SELECT_NEW); } else { $new_products_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id = '" . (int)$new_products_category_id . "' and p.products_status = '1' order by p.products_date_added desc limit " . MAX_RANDOM_SELECT_NEW); // end random new products } // start random new products // To configure: // // Under Admin - Configuration - Maximum Values // Set the following: // 'Selection of Random New Products' // (MAX_RANDOM_SELECT_NEW) - Sets how many of the most recent new product entries are queried // 'New Products Module' // (MAX_DISPLAY_NEW_PRODUCTS) - Sets how many random new products are displayed on screen // $row = 0; $col = 0; $pCount = 0; $info_box_contents = array(); $found_products = array(); $num_rows = tep_db_num_rows($new_products_query); if (MAX_DISPLAY_NEW_PRODUCTS > MAX_RANDOM_SELECT_NEW) { // don't allow more new products than will be queried $max_new_products = MAX_RANDOM_SELECT_NEW; } elseif (MAX_DISPLAY_NEW_PRODUCTS > tep_db_num_rows($new_products_query)) { $max_new_products = tep_db_num_rows($new_products_query); } else { $max_new_products = MAX_DISPLAY_NEW_PRODUCTS; } if ($num_rows > 0) { while ($pCount < $max_new_products) { // choose a random row $random_product = ''; $random_row = tep_rand(0, ($num_rows - 1)); tep_db_data_seek($new_products_query, $random_row); $random_product = tep_db_fetch_array($new_products_query); // see if found already, if not use else skip $found = 0; for ($ii=0; $ii < $pCount; $ii++) { if ($found_products[$ii] == $random_product['products_id']) { $found = 1; break; } } if ($found == 0) { // keep track of found id's $found_products[$pCount] += $random_product['products_id']; $pCount ++; // add to display array $random_product['products_name'] = tep_get_products_name($random_product['products_id']); $info_box_contents[$row][$col] = array('align' => 'center', 'params' => 'class="smallText" width="33%" valign="top"', 'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $random_product['products_image'], $random_product['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product['products_id']) . '">' . $random_product['products_name'] . '</a><br>' . $currencies->display_price($random_product['products_price'], tep_get_tax_rate($random_product['products_tax_class_id']))); $col ++; if ($col > 2) { $col = 0; $row ++; } } // found } // while pCount } // num_rows // end random new products new contentBox($info_box_contents); ?> <!-- new_products_eof //--> ****************************************************************** now in the original download file by mr. fox, i read the instructions on how to change: Configuration This uses two existing Configuration Values under Admin - Configuration - Maximum Values Selection of Random New Products: Sets how many of the most recent new product entries are queried. This can vary based on how far back you want to go to display new products. New Products Module: Sets how many random new products are displayed on screen. This is typically 9. ------THERE IS NO Randon New Products for me to choose though. I also don't understand the part where it says, "If you need to merge this change based on 2.2MS2 Replace Lines 19 - 23 with 23 - 27 Replace Lines 25 - 41 with 29 - 84" What does this relate to? AM I THE ONLY ONE WHO HAS A PROBLEM SETTING UP THIS CONTRIBUTION? If there is a better one for me to use, please direct me down the right path. I kind of liked this man's script because I went to his website: http://birdsupplynh.com and it worked fine on his page so I wanted to give it a try on mine. thank you so much for your time and patience with me. adieu, macie
Guest Posted July 18, 2004 Posted July 18, 2004 My gosh, Don't I feel dumb? My site now works all of the sudden...afer i was messing with some of the files. I am completely dumbfounded though as to how I did it. I'm sorry if this has been a useless post. If you have similar issues with this contribution, please just added on here. Adieu, Macie
Recommended Posts
Archived
This topic is now archived and is closed to further replies.