jhande Posted May 14, 2009 Posted May 14, 2009 I tried searching but be darned if I can find it and I'm certainly unable to figure it out myself. :blush: As I mentioned, I stumbled across an edit so I can set how old or recent the the New for Month of module will display. Right now I have it set to display any products that have been added in the past 30 days. BUT... <_< When there's no products to display, the table header still shows and of course no products listed under it. I'd really like it to disappear when there's no products to display. Any ideas? - :: Jim :: - - My Toolbox ~ Adobe Web Bundle, XAMPP & WinMerge | Install ~ osC v2.3.3.4 -
jhande Posted May 14, 2009 Author Posted May 14, 2009 I tried adding - if (tep_db_num_rows($expected_query) > 0) to the new_products.php but received all kinds of errors. I'm sure it must be some simple PHP code, but I haven't been able to figure out what or where. :blush: I "think" it should be placed somewhere amongst this bit of code (but I could be wrong as usual)... <!-- new_products //--> <?php $info_box_contents = array(); // $info_box_contents[] = array('text' => sprintf(TABLE_HEADING_NEW_PRODUCTS, strftime('%B'))); /* delete month from heading */ $info_box_contents[] = array('text' => (TABLE_HEADING_NEW_PRODUCTS));</P> <P> new contentBoxHeading($info_box_contents);</P> <P>$days_of_new_products = 30; //** Change the 30 to how many days to display **// $unix_days_of_new_products = $days_of_new_products * 86400;</P> <P> if ( (!isset($new_products_category_id)) || ($new_products_category_id == '0') ) { $new_products_query = tep_db_query("select p.products_date_added, 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' AND TO_DAYS(NOW()) - TO_DAYS(p.products_date_added) < ".$days_of_new_products." order by rand() desc limit " . MAX_DISPLAY_NEW_PRODUCTS); } else { $new_products_query = tep_db_query("select distinct p.products_date_added, 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' AND TO_DAYS(NOW()) - TO_DAYS(p.products_date_added) < ".$days_of_new_products." order by rand() desc limit " . MAX_DISPLAY_NEW_PRODUCTS); } :blink: - :: Jim :: - - My Toolbox ~ Adobe Web Bundle, XAMPP & WinMerge | Install ~ osC v2.3.3.4 -
burt Posted May 14, 2009 Posted May 14, 2009 Get rid all that crappy code for starters. <!-- new_products //--> <?php if ( (!isset($new_products_category_id)) || ($new_products_category_id == '0') ) { //$new_products_query = tep_db_query("select p.products_id, p.products_image, p.products_tax_class_id, pd.products_name, 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_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 limit " . MAX_DISPLAY_NEW_PRODUCTS); $new_products_query = tep_db_query("select p.products_id, p.products_image, p.products_tax_class_id, pd.products_name, 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_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' AND p.products_date_added > date_sub(NOW(), INTERVAL 1 MONTH) order by rand() limit " . MAX_DISPLAY_NEW_PRODUCTS); } else { $new_products_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, pd.products_name, 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_DESCRIPTION . " pd, " . 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' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' AND p.products_date_added > date_sub(NOW(), INTERVAL 1 MONTH) order by rand() limit " . MAX_DISPLAY_NEW_PRODUCTS); } if (tep_db_num_rows($new_products_query) > 0) { $info_box_contents = array(); $info_box_contents[] = array('text' => sprintf(TABLE_HEADING_NEW_PRODUCTS, strftime('%B'))); new contentBoxHeading($info_box_contents); $row = 0; $col = 0; $info_box_contents = array(); while ($new_products = tep_db_fetch_array($new_products_query)) { $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=' . $new_products['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $new_products['products_image'], $new_products['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id']) . '">' . $new_products['products_name'] . '</a><br>' . $currencies->display_price($new_products['products_price'], tep_get_tax_rate($new_products['products_tax_class_id']))); $col ++; if ($col > 2) { $col = 0; $row ++; } } new contentBox($info_box_contents); } ?> <!-- new_products_eof //-->
jhande Posted May 14, 2009 Author Posted May 14, 2009 AWESOME... Thanks a million Burt! ;) :D - :: Jim :: - - My Toolbox ~ Adobe Web Bundle, XAMPP & WinMerge | Install ~ osC v2.3.3.4 -
larryh001 Posted May 20, 2009 Posted May 20, 2009 Get rid all that crappy code for starters. <!-- new_products //--> <?php if ( (!isset($new_products_category_id)) || ($new_products_category_id == '0') ) { //$new_products_query = tep_db_query("select p.products_id, p.products_image, p.products_tax_class_id, pd.products_name, 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_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 limit " . MAX_DISPLAY_NEW_PRODUCTS); $new_products_query = tep_db_query("select p.products_id, p.products_image, p.products_tax_class_id, pd.products_name, 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_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' AND p.products_date_added > date_sub(NOW(), INTERVAL 1 MONTH) order by rand() limit " . MAX_DISPLAY_NEW_PRODUCTS); } else { $new_products_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, pd.products_name, 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_DESCRIPTION . " pd, " . 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' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' AND p.products_date_added > date_sub(NOW(), INTERVAL 1 MONTH) order by rand() limit " . MAX_DISPLAY_NEW_PRODUCTS); } if (tep_db_num_rows($new_products_query) > 0) { $info_box_contents = array(); $info_box_contents[] = array('text' => sprintf(TABLE_HEADING_NEW_PRODUCTS, strftime('%B'))); new contentBoxHeading($info_box_contents); $row = 0; $col = 0; $info_box_contents = array(); while ($new_products = tep_db_fetch_array($new_products_query)) { $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=' . $new_products['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $new_products['products_image'], $new_products['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id']) . '">' . $new_products['products_name'] . '</a><br>' . $currencies->display_price($new_products['products_price'], tep_get_tax_rate($new_products['products_tax_class_id']))); $col ++; if ($col > 2) { $col = 0; $row ++; } } new contentBox($info_box_contents); } ?> <!-- new_products_eof //-->
larryh001 Posted May 20, 2009 Posted May 20, 2009 No problem. Hi, Burt, Could you please tell me how to set how old or recent products to display in the "new products" module? the default version of new products module shows the products for the current month, however, i would like it to show the all year even all products page by page--how to do it? Thanks in advance! larry
jhande Posted May 20, 2009 Author Posted May 20, 2009 Hi, Burt, Could you please tell me how to set how old or recent products to display in the "new products" module? the default version of new products module shows the products for the current month, however, i would like it to show the all year even all products page by page--how to do it? Thanks in advance! larry Did you not notice this - INTERVAL 1 MONTH in the code? ;) - :: Jim :: - - My Toolbox ~ Adobe Web Bundle, XAMPP & WinMerge | Install ~ osC v2.3.3.4 -
larryh001 Posted May 21, 2009 Posted May 21, 2009 Did you not notice this - INTERVAL 1 MONTH in the code? ;) Yes, I changed 1 month to 6 months. However, it only shows limited products, say 30 products in the front page(I may have 1000 products in 6 months, I want to display all of them page by page, in stead of only 30 items), it has no NEXT page available like the ALL PRODUCTS module does. Do you have any ideas about that? Thanks for your reply! larryh
jhande Posted May 21, 2009 Author Posted May 21, 2009 Yes, I changed 1 month to 6 months. However, it only shows limited products, say 30 products in the front page(I may have 1000 products in 6 months, I want to display all of them page by page, in stead of only 30 items), it has no NEXT page available like the ALL PRODUCTS module does. Do you have any ideas about that? Thanks for your reply!larryh I appologize Larry, I did not totally understand what you were trying to do. :blush: I really don't know much regarding PHP, but I would look for where - MAX_DISPLAY_NEW_PRODUCTS is defined or compare the code with the all products module. Have you checked the contributions? Possibly there is something that you might be able to use?? - :: Jim :: - - My Toolbox ~ Adobe Web Bundle, XAMPP & WinMerge | Install ~ osC v2.3.3.4 -
Recommended Posts
Archived
This topic is now archived and is closed to further replies.