Jump to content


Corporate Sponsors


Latest News: (loading..)

- - - - -

new_products.php span across multiple pages


2 replies to this topic

#1 ridgebacktech

  • Community Member
  • 5 posts
  • Real Name:Joshua Moore

Posted 22 November 2009, 16:53

Hello guys,
I have been working on the new_products.php module in OSC for quite some time. I managed to go from scratch to this:

All on my own. However, I have run into a road block. What I am trying to do is get the page to span across multiple pages (1, 2, 3, etc) after 20 are listed. So, in other words, when the new_products.php parses the 21st item, it will be placed on a separate page and a corresponding page link will be shown at the top or bottom of the page.

Here is the code in my current new_products.php:

<?php
/*
  $Id: new_products.php 1806 2008-01-11 22:48:15Z hpdl $

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2008 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') ) {
    $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.latest_product='1'and 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);
  } 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.latest_product='1' and 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 . "' order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS);
  }

  $row = 0;
  $col = 0;
  $info_box_contents = array();
  while ($new_products = tep_db_fetch_array($new_products_query)) {
    $new_products['products_name'] = tep_get_products_name($new_products['products_id']);
    $info_box_contents[$row][$col] = array('align' => 'left',
                                           'params' => 'class="productListing-data" width="20%" 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><td class="productListing-data" valign="middle"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id']) . '">' . $new_products['products_name'] . '</a></td><td class="productListing-data" valign="middle" align="right">' . $currencies->display_price($new_products['products_price'], tep_get_tax_rate($new_products['products_tax_class_id']))
										 . '</td><td class="smallText" valign="middle">' . tep_draw_form('cart_quantity', tep_href_link(FILENAME_PRODUCT_INFO, tep_get_all_get_params(array('action')) . 'products_id=' . $new_products['products_id'] . '&action=add_product')) . tep_draw_hidden_field('products_id', $new_products['products_id']) . tep_image_submit('button_buy_now.gif', IMAGE_BUTTON_IN_CART) . '</form></td><table><br><br>');
    $col ++;
    if ($col > 0) {
      $col = 0;
      $row ++;
    }
  }

  new contentBox($info_box_contents);
?>
<!-- new_products_eof //-->

If anyone could provide some help or tips, it would be greatly appreciated!

Thanks.

Edited by ridgebacktech, 22 November 2009, 16:58.


#2 geoffreywalton

  • Community Sponsor
  • 7,617 posts
  • Real Name:Geoffrey Walton
  • Gender:Male
  • Location:Norfolk, UK (close to the centre of the universe)

Posted 22 November 2009, 21:37

This fuctionality is a already in new_products.php so not sure why you doing this

Look in the admin area for

New Products Module

http://localhost/sone/d5gru/configuration.php?gID=3
Need help installing add ons/contributions, cleaning a hacked site or a bespoke development, check my profile

Virus Threat Scanner
My Contributions
Basic install answers.
Click here for Contributions / Add Ons.
UK your site.
Site Move.
Basic design info.

For links mentioned in old answers that are no longer here follow this link Useful Threads.

If this post was useful, click the Like This button over there ======>>>>>.

#3 ridgebacktech

  • Community Member
  • 5 posts
  • Real Name:Joshua Moore

Posted 26 November 2009, 01:35

That places all items on a single page though. I need the products to span across multiple pages.