Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

New field in Product listing - Sort order problem


-Buggi-

Recommended Posts

Posted

Hi

 

I have, after numerous of hours, finally "given up".

I have installed the contrib. "New_field_everywhere", and after a (long) while, I finally got everything working with the heavily moddet shop that I´m setting up for a friend.

One thing, though, is not working at all, and that is the Sort Order in the new field in the product listing.

The sorting is for some reason "connected" with the product name, so that it follows the sorting in the "Product name" column (in Danish "Produkt navn")

The strange thing is, that i work perfectly in the "advanced_search_result"!?

 

I have tried almost any possible constellation in my "index.php" and "product_listing.php", as I assume that it is in one of these two files my problem is!?

 

Any help would be deeply appreciated.. :)

 

Below is my "index.php" and my "product_listing.php"

 

The code/extra field is named PRICE_PER_PIECE

 

Link to site is: www.plade-klassikeren.dk

 

<?php
/*
 $Id: index.php,v 1.1 2003/06/11 17:37:59 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');

// the following cPath references come from application_top.php
 $category_depth = 'top';
 if (isset($cPath) && tep_not_null($cPath)) {
   $categories_products_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id = '" . (int)$current_category_id . "'");
   $cateqories_products = tep_db_fetch_array($categories_products_query);
   if ($cateqories_products['total'] > 0) {
     $category_depth = 'products'; // display products
   } else {
     $category_parent_query = tep_db_query("select count(*) as total from " . TABLE_CATEGORIES . " where parent_id = '" . (int)$current_category_id . "'");
     $category_parent = tep_db_fetch_array($category_parent_query);
     if ($category_parent['total'] > 0) {
       $category_depth = 'nested'; // navigate through the categories
     } else {
       $category_depth = 'products'; // category has no products, but display the 'no products' message
     }
   }
 }

 require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_DEFAULT);

if ($category_depth == 'top') {
 $breadcrumb_title->add(STORE_NAME . ' » ' . NAVBAR_TITLE);
}

?>
<!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
if (($c_pagetitle != '') && (CATEGORIES_INDIVIDUAL_PAGE_TITLE == 'Ja')) {
 echo $c_pagetitle;
} else {
 echo $breadcrumb_title->trail(' » ');
}
?></title>
<?php
if (($c_meta_keywords != '') && (CATEGORIES_INDIVIDUAL_META_KEYWORDS == 'Ja')) {
 echo '<meta name="keywords" content="' . $c_meta_keywords . '" />' . "\n";
}
if (($c_meta_description != '') && (CATEGORIES_INDIVIDUAL_META_DESCRIPTION == 'Ja')) {
 echo '<meta name="description" content="' . $c_meta_description . '" />' . "\n";
}
?>
<base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
<script type="text/javascript" src="scripts/lightbox/prototype.js"></script>
<script type="text/javascript" src="scripts/lightbox/scriptaculous.js?load=effects,builder"></script>
<script type="text/javascript" src="scripts/lightbox/lightbox.js"></script>
<link rel="stylesheet" href="scripts/lightbox/lightbox.css" type="text/css" media="screen" />
</head>
<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="100%" cellspacing="0" cellpadding="0" class="pageBody">
<tr>

<?php
 if (LAYOUT_COLUMN_LEFT_SHOW == 'Ja') {
?>

<td width="<?php echo LAYOUT_COLUMN_LEFT_WIDTH; ?>" valign="top" class="columnLeft">

 <table border="0" width="<?php echo LAYOUT_COLUMN_LEFT_WIDTH; ?>" cellspacing="0" cellpadding="0">

<!-- left_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
<!-- left_navigation_eof //-->

 </table>

</td>

<?php
 }
?>

<!-- body_text //-->
<?php
 if ($category_depth == 'nested') {
$category_query = tep_db_query("select cd.categories_name, c.categories_image,cd.categories_description,cd.categories_heading_title from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = '" . (int)$current_category_id . "' and cd.categories_id = '" . (int)$current_category_id . "' and cd.language_id = '" . (int)$languages_id . "'");
   $category = tep_db_fetch_array($category_query);
?>
<td width="100%" valign="top" class="columnCenter">

 <table border="0" width="100%" cellspacing="0" cellpadding="0" class="pageContents">
 <tr>
 <td class="pageContents">

   <table border="0" width="100%" cellspacing="0" cellpadding="0">
     <tr>
       <td>

       <table border="0" width="100%" cellspacing="0" cellpadding="0" class="pageHeading">
         <tr>
   <td class="pageHeading"><h1><?php echo (!empty($category['categories_heading_title']) ? $category['categories_heading_title'] : HEADING_TITLE); ?></h1></td>

<?php
// added by GrafikStudiet
 if (LAYOUT_SHOW_PAGE_HEADING_ICON == 'Ja') {
?>

           <td class="pageHeading" align="right"><?php echo tep_image(DIR_WS_IMAGES . $category['categories_image'], $category['categories_name'], HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>

<?php
 }
?>

   </tr>
   <tr>

   <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '3'); ?></td>
   </tr>
   </table></td>
     </tr>
   <tr>
   <td class="categoryDescription"><?php echo $category['categories_description']; ?></td>
   </tr>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
     </tr>
     <tr>
       <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
         <tr>
           <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
             <tr>
<?php
   if (isset($cPath) && strpos('_', $cPath)) {
// check to see if there are deeper categories within the current category
     $category_links = array_reverse($cPath_array);
     for($i=0, $n=sizeof($category_links); $i<$n; $i++) {
       $categories_query = tep_db_query("select count(*) as total from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$category_links[$i] . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "'");
       $categories = tep_db_fetch_array($categories_query);
       if ($categories['total'] < 1) {
         // do nothing, go through the loop
       } else {
         $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.categories_image, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$category_links[$i] . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' order by sort_order, cd.categories_name");
         break; // we've found the deepest category the customer is in
       }
     }
   } else {
     $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.categories_image, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$current_category_id . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' order by sort_order, cd.categories_name");
   }

   $number_of_categories = tep_db_num_rows($categories_query);

   $rows = 0;
   while ($categories = tep_db_fetch_array($categories_query)) {
     $rows++;
     $cPath_new = tep_get_path($categories['categories_id']);
     $width = (int)(100 / MAX_DISPLAY_CATEGORIES_PER_ROW) . '%';
     echo '                <td align="center" class="smallText" width="' . $width . '" valign="top"><a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">' . tep_image(DIR_WS_IMAGES . $categories['categories_image'], $categories['categories_name'], SUBCATEGORY_IMAGE_WIDTH, SUBCATEGORY_IMAGE_HEIGHT) . '<br><h3>' . $categories['categories_name'] . '</h3></a></td>' . "\n";
     if ((($rows / MAX_DISPLAY_CATEGORIES_PER_ROW) == floor($rows / MAX_DISPLAY_CATEGORIES_PER_ROW)) && ($rows != $number_of_categories)) {
       echo '              </tr>' . "\n";
       echo '              <tr>' . "\n";
     }
   }

// needed for the new products module shown below
   $new_products_category_id = $current_category_id;
?>
             </tr>
           </table></td>
         </tr>
         <tr>
           <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
         </tr>
         <tr>
           <td><?php include(DIR_WS_MODULES . FILENAME_NEW_PRODUCTS); ?></td>
         </tr>
       </table></td>
     </tr>
   </table>
     </td>
 </tr>
 </table>

   </td>
<?php
 } elseif ($category_depth == 'products' || isset($HTTP_GET_VARS['manufacturers_id'])) {
// create column list
//sort order
   $define_list = array('PRODUCT_LIST_SORT_ORDER' => PRODUCT_LIST_SORT_ORDER,
                        'PRODUCT_LIST_MODEL' => PRODUCT_LIST_MODEL,
//end sort order


                        'PRODUCT_LIST_NAME' => PRODUCT_LIST_NAME,
                        'PRODUCT_LIST_SHORT_DESCRIPTION' => PRODUCT_LIST_SHORT_DESCRIPTION,
                        'PRODUCT_LIST_MANUFACTURER' => PRODUCT_LIST_MANUFACTURER,
                        'PRODUCT_LIST_PRICE' => PRODUCT_LIST_PRICE,
                        'PRODUCT_LIST_PRICE_PER_PIECE' => PRODUCT_LIST_PRICE_PER_PIECE,
                        'PRODUCT_LIST_QUANTITY' => PRODUCT_LIST_QUANTITY,
                        'PRODUCT_LIST_WEIGHT' => PRODUCT_LIST_WEIGHT,
                        'PRODUCT_LIST_IMAGE' => PRODUCT_LIST_IMAGE,
                        'PRODUCT_LIST_BUY_NOW' => PRODUCT_LIST_BUY_NOW);

   asort($define_list);

   $column_list = array();
   reset($define_list);
   while (list($key, $value) = each($define_list)) {
     if ($value > 0) $column_list[] = $key;
   }

   $select_column_list = '';

   for ($i=0, $n=sizeof($column_list); $i<$n; $i++) {
     switch ($column_list[$i]) {
//sort order
       case 'PRODUCT_LIST_SORT_ORDER':
         $select_column_list .= 'p.products_sort_order, ';
         break;
//end sort order
       case 'PRODUCT_LIST_MODEL':
         $select_column_list .= 'p.products_model, ';
         break;

       case 'PRODUCT_LIST_NAME':
         $select_column_list .= 'pd.products_name, pd.products_short_description, ';
         break;
       case 'PRODUCT_LIST_MANUFACTURER':
         $select_column_list .= 'm.manufacturers_name, ';
         break;
         case 'PRODUCT_LIST_PRICE_PER_PIECE':
         $select_column_list .= 'p.products_price_per_piece, ';
         break;
       case 'PRODUCT_LIST_NOTES':
         $select_column_list .= 'p.products_notes, ';
         break;
       case 'PRODUCT_LIST_QUANTITY':
         $select_column_list .= 'p.products_quantity, ';
         break;
       case 'PRODUCT_LIST_IMAGE':
         $select_column_list .= 'p.products_image, ';
         break;
       case 'PRODUCT_LIST_WEIGHT':
         $select_column_list .= 'p.products_weight, ';
         break;
     }
   }

// show the products of a specified manufacturer
   if (isset($HTTP_GET_VARS['manufacturers_id'])) {
     if (isset($HTTP_GET_VARS['filter_id']) && tep_not_null($HTTP_GET_VARS['filter_id'])) {
// We are asked to show only a specific category
       $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_status = '1' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$HTTP_GET_VARS['filter_id'] . "'";
     } else {
// We show them all
       $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m where p.products_status = '1' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "'";
     }
   } else {
// show the products in a given categorie
     if (isset($HTTP_GET_VARS['filter_id']) && tep_not_null($HTTP_GET_VARS['filter_id'])) {
// We are asked to show only specific catgeory
       $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_status = '1' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['filter_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$current_category_id . "'";
     } else {
// We show them all
       $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_status = '1' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$current_category_id . "'";
     }
   }

   if ( (!isset($HTTP_GET_VARS['sort'])) || (!ereg('^[1-8][ad]$', $HTTP_GET_VARS['sort'])) || (substr($HTTP_GET_VARS['sort'], 0, 1) > sizeof($column_list)) ) {
     for ($i=0, $n=sizeof($column_list); $i<$n; $i++) {
//sort order
       if ($column_list[$i] == 'PRODUCT_LIST_SORT_ORDER') {
         $HTTP_GET_VARS['sort'] = $i+1 . 'a';
         $listing_sql .= " order by p.products_sort_order, pd.products_name";

         break;
       }
       elseif ($column_list[$i] == 'PRODUCT_LIST_NAME' && PRODUCT_LIST_SORT_ORDER==0) {
         $HTTP_GET_VARS['sort'] = $i+1 . 'a';
         $listing_sql .= " order by pd.products_name";
//end sort order
         break;
       }
     }
   } else {
     $sort_col = substr($HTTP_GET_VARS['sort'], 0 , 1);
     $sort_order = substr($HTTP_GET_VARS['sort'], 1);

     switch ($column_list[$sort_col-1]) {
   //sort order
   case 'PRODUCT_LIST_SORT_ORDER':
   $listing_sql .= " order by p.products_sort_order , pd.products_name " . ($sort_order == 'a' ? 'asc' : '');
   break;
   //end sort order
       case 'PRODUCT_LIST_MODEL':
         $listing_sql .= " order by p.products_model " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
         break;
       case 'PRODUCT_LIST_MSRP':
         $listing_sql .= "p.products_price_per_piece " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
         break;
       case 'PRODUCT_LIST_MSRP':
         $listing_sql .= "p.products_notes " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
         break;
       case 'PRODUCT_LIST_NAME':
         $listing_sql .= " order by pd.products_name " . ($sort_order == 'd' ? 'desc' : '');
         break;
       case 'PRODUCT_LIST_SHORT_DESCRIPTION':
         $listing_sql .= "pd.products_short_description ". ($sort_order == 'd' ? 'desc' : '');
         break;
       case 'PRODUCT_LIST_MANUFACTURER':
         $listing_sql .= " order by m.manufacturers_name " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
         break; 
       case 'PRODUCT_LIST_QUANTITY':
         $listing_sql .= " order by p.products_quantity " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
         break;
       case 'PRODUCT_LIST_IMAGE':
         $listing_sql .= " order by pd.products_name";
         break;
       case 'PRODUCT_LIST_WEIGHT':
         $listing_sql .= " order by p.products_weight " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
         break;
       case 'PRODUCT_LIST_PRICE':
         $listing_sql .= " order by final_price " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
         break;
     }
   }
   $cat_description_query = tep_db_query ("select categories_heading_title, categories_description from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id = '" . $current_category_id . "' and language_id = '" . (int)$languages_id . "'");
 $cat_description = tep_db_fetch_array ($cat_description_query);
?>
<td width="100%" valign="top" class="columnCenter">

 <table border="0" width="100%" cellspacing="0" cellpadding="0" class="pageContents">
 <tr>
 <td class="pageContents">

   <table border="0" width="100%" cellspacing="0" cellpadding="0">
     <tr>
       <td><table border="0" width="100%" cellspacing="0" cellpadding="0" class="pageHeading">
         <tr>
           <td class="pageHeading"><h1><?php echo (!empty($cat_description['categories_heading_title']) ? $cat_description['categories_heading_title'] : HEADING_TITLE); ?></td>
<?php
// optional Product List Filter
   if (PRODUCT_LIST_FILTER > 0) {
     if (isset($HTTP_GET_VARS['manufacturers_id'])) {
       $filterlist_sql = "select distinct c.categories_id as id, cd.categories_name as name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where p.products_status = '1' and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and p2c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' and p.manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "' order by cd.categories_name";
     } else {
       $filterlist_sql= "select distinct m.manufacturers_id as id, m.manufacturers_name as name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_MANUFACTURERS . " m where p.products_status = '1' and p.manufacturers_id = m.manufacturers_id and p.products_id = p2c.products_id and p2c.categories_id = '" . (int)$current_category_id . "' order by m.manufacturers_name";
     }
     $filterlist_query = tep_db_query($filterlist_sql);
     if (tep_db_num_rows($filterlist_query) > 1) {
       echo '            <td align="center" class="main">' . tep_draw_form('filter', FILENAME_DEFAULT, 'get') . TEXT_SHOW . ' ';
       if (isset($HTTP_GET_VARS['manufacturers_id'])) {
         echo tep_draw_hidden_field('manufacturers_id', $HTTP_GET_VARS['manufacturers_id']);
         $options = array(array('id' => '', 'text' => TEXT_ALL_CATEGORIES));
       } else {
         echo tep_draw_hidden_field('cPath', $cPath);
         $options = array(array('id' => '', 'text' => TEXT_ALL_MANUFACTURERS));
       }
       echo tep_draw_hidden_field('sort', $HTTP_GET_VARS['sort']);
       while ($filterlist = tep_db_fetch_array($filterlist_query)) {
         $options[] = array('id' => $filterlist['id'], 'text' => $filterlist['name']);
       }
       echo tep_draw_pull_down_menu('filter_id', $options, (isset($HTTP_GET_VARS['filter_id']) ? $HTTP_GET_VARS['filter_id'] : ''), 'onchange="this.form.submit()"');
       echo tep_hide_session_id() . '</form></td>' . "\n";
     }
   }

// Get the right image for the top-right
   $image = DIR_WS_IMAGES . 'table_background_list.gif';
   if (isset($HTTP_GET_VARS['manufacturers_id'])) {
     $image = tep_db_query("select manufacturers_image from " . TABLE_MANUFACTURERS . " where manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "'");
     $image = tep_db_fetch_array($image);
     $image = $image['manufacturers_image'];
   } elseif ($current_category_id) {
     $image = tep_db_query("select categories_image from " . TABLE_CATEGORIES . " where categories_id = '" . (int)$current_category_id . "'");
     $image = tep_db_fetch_array($image);
     $image = $image['categories_image'];
   }
?>

<?php
// added by GrafikStudiet
 if (LAYOUT_SHOW_PAGE_HEADING_ICON == 'Ja') {
?>

           <td class="pageHeading" align="right"><?php echo tep_image(DIR_WS_IMAGES . $image, (!empty($cat_description['categories_heading_title']) ? $cat_description['categories_heading_title'] : HEADING_TITLE), HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT, 'ALIGN=right'); ?></td>

<?php
 }
?>

         </tr>
   <tr>
   <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '3'); ?></td>
   </tr>
   </table></td>
     </tr>
   <tr>
   <td class="categoryDescription"><?php echo $cat_description['categories_description']; ?></td>
   </tr>
<!-- BOF: Show subcategories in Product Listing -->
   <tr>
<td><table border="0" width="100%" cellspacing="0" cellpadding="2"><tr><?php
       if (isset($cPath)) {
		if (ereg('_', $cPath)) {
			$category_links = array_reverse($cPath_array);
			$cat_to_search = $category_links[0];
			}
		else {
			$cat_to_search = $cPath;
			}
	    // check to see if there are deeper categories within the current category		  	
	  	$categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.categories_image, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . $cat_to_search . "' and c.categories_id = cd.categories_id and cd.language_id = '" . $languages_id . "' order by sort_order, cd.categories_name");
		    if (tep_db_num_rows($categories_query) > 0 ) {
			    $rows = 0;
				while ($categories = tep_db_fetch_array($categories_query)) {
				    $rows++;
					$cPath_new = tep_get_path($categories['categories_id']);
					$width = (int)(100 / MAX_DISPLAY_CATEGORIES_PER_ROW) . '%';
					echo '                <td align="center" class="smallText" style="width: ' . $width . '" valign="top"><a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">' . tep_image(DIR_WS_IMAGES . $categories['categories_image'], $categories['categories_name'], SUBCATEGORY_IMAGE_WIDTH, SUBCATEGORY_IMAGE_HEIGHT) . '<br>' . $categories['categories_name'] . '</a></td>' . "\n";
					if ((($rows / MAX_DISPLAY_CATEGORIES_PER_ROW) == floor($rows / MAX_DISPLAY_CATEGORIES_PER_ROW)) && ($rows != tep_db_num_rows($categories_query))) {
						echo '              </tr>' . "\n";
						echo '              <tr>' . "\n";
						}
				}
			}
	}						
   ?></tr></table></td>
</tr>
<tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
   </tr>
<!-- EOF: Show subcategories in Product Listing -->    
     <tr>
       <td><?php include(DIR_WS_MODULES . FILENAME_PRODUCT_LISTING); ?></td>
     </tr>
   </table>
     </td>
 </tr>
 </table>

   </td>
<?php
 } else { // default page
?>

<td width="100%" valign="top" class="columnCenter">

 <table border="0" width="100%" cellspacing="0" cellpadding="0" class="pageContents">
 <tr>
 <td class="pageContents">

     <table border="0" width="100%" cellspacing="0" cellpadding="0">

<?php
 if ( INDEX_ADMIN_SHOW_HEADING == 'Ja') {
?>

     <tr>
     <td>

       <table border="0" width="100%" cellspacing="0" cellpadding="0" class="pageHeading">
       <tr>
       <td class="pageHeading"><h1><?php echo HEADING_TITLE; ?></h1></td>

<?php
// added by GrafikStudiet
   if (LAYOUT_SHOW_PAGE_HEADING_ICON == 'Ja') {
?>

       <td class="pageHeading" align="right"><?php echo tep_image(DIR_WS_IMAGES . 'table_background_default.gif', HEADING_TITLE, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>

<?php
   }
?>

       </tr>
       <tr>
       <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '3'); ?></td>
       </tr>
       </table>

     </td>
     </tr>
     <tr>
     <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
     </tr>

<?php
 }
?>

     <tr>
     <td>

       <table border="0" width="100%" cellspacing="0" cellpadding="0">

<?php
 if ( INDEX_ADMIN_SHOW_CUSTOMER_GREETING == 'Ja') {
?>
       <tr>
       <td class="main"><?php echo tep_customer_greeting(); ?></td>
       </tr>
       <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
       </tr>

<?php
}
 if ( INDEX_ADMIN_SHOW_CATEGORIES == 'Ja') {
?>

       <tr>
       <td><?php include(DIR_WS_MODULES . FILENAME_SHOW_CATEGORIES); ?></td>
       </tr>
       <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
       </tr>

<?php
}
 if ( INDEX_ADMIN_SHOW_CUSTOM_CONTENTS == 'Ja') {
?>

       <tr>
       <td class="main"><?php include(DIR_WS_LANGUAGES . $language . '/' . FILENAME_CONTENTS_MAINPAGE);?></td>
       </tr>
       <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
       </tr>

<?php
}
 if ( INDEX_ADMIN_SHOW_RANDOM_PRODUCTS == 'Ja') {
?>

       <tr>
       <td><?php include(DIR_WS_MODULES . FILENAME_RANDOM_PRODUCTS); ?></td>
       </tr>
       <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
       </tr>

<?php
}
 if ( INDEX_ADMIN_SHOW_NEW_PRODUCTS == 'Ja') {
?>

       <tr>
       <td><?php include(DIR_WS_MODULES . FILENAME_NEW_PRODUCTS); ?></td>
       </tr>
       <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
       </tr>

<?php
}
 if ( INDEX_ADMIN_SHOW_UPCOMING_PRODUCTS == 'Ja') {
?>

       <tr>
       <td><?php include(DIR_WS_MODULES . FILENAME_UPCOMING_PRODUCTS); ?></td>
       </tr>
       <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
       </tr>

<?php
 }
?>
       </table>

     </td>
     </tr>
     </table>
 </td>
 </tr>
 </table>

</td>

<?php
 }
?>

<!-- body_text_eof //-->

<?php
// added by GrafikStudiet
 if (LAYOUT_COLUMN_RIGHT_SHOW == 'Ja') {
?>

<td width="<?php echo LAYOUT_COLUMN_RIGHT_WIDTH; ?>" valign="top" class="columnRight">

 <table border="0" width="<?php echo LAYOUT_COLUMN_RIGHT_WIDTH; ?>" cellspacing="0" cellpadding="0">

<!-- right_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_right.php'); ?>
<!-- right_navigation_eof //-->

 </table>

</td>

<?php
 }
?>

</tr>
</table>
<!-- body_eof //-->
<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->

</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

 

<?php
/*
 $Id: product_listing.php,v 1.44 2003/06/09 22:49:59 hpdl Exp $

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

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

 if (isset($pw_mispell)){
//added for search enhancements mod
?>
<table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr><td><?php echo $pw_string; ?></td></tr>
</table>
<?php
}
//end added search enhancements mod
 $listing_split = new splitPageResults($listing_sql, MAX_DISPLAY_SEARCH_RESULTS, 'p.products_id');
// fix counted products
 if ( ($listing_split->number_of_rows > 0) && ( (PREV_NEXT_BAR_LOCATION == '1') || (PREV_NEXT_BAR_LOCATION == '3') ) ) {
?>
<table border="0" width="100%" cellspacing="0" cellpadding="3">
 <tr>
   <td class="smallText"><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></td>
   <td class="smallText" align="right"><?php echo TEXT_RESULT_PAGE . ' ' . $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></td>
 </tr>
</table>
<?php
 }

 $list_box_contents = array();

 for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
   switch ($column_list[$col]) {
     case 'PRODUCT_LIST_MODEL':
       $lc_text = TABLE_HEADING_MODEL;
       $lc_align = '';
       break;
     case 'PRODUCT_LIST_PRICE_PER_PIECE':
       $lc_text = TABLE_HEADING_PRICE_PER_PIECE;
       $lc_align = '';
       break;
     case 'PRODUCT_LIST_NOTES':
       $lc_text = TABLE_HEADING_NOTES;
       $lc_align = '';
       break;
     case 'PRODUCT_LIST_NAME':
       $lc_text = TABLE_HEADING_PRODUCTS;
       $lc_align = '';
       break;
     case 'PRODUCT_LIST_SHORT_DESCRIPTION':
       $lc_text = TABLE_HEADING_SHORT_DESCRIPTION;
       $lc_align = '';
       break;
     case 'PRODUCT_LIST_MANUFACTURER':
       $lc_text = TABLE_HEADING_MANUFACTURER;
       $lc_align = '';
       break;
     case 'PRODUCT_LIST_PRICE':
       $lc_text = TABLE_HEADING_PRICE;
       $lc_align = 'right';
       break;
     case 'PRODUCT_LIST_QUANTITY':
       $lc_text = TABLE_HEADING_QUANTITY;
       $lc_align = 'right';
       break;
     case 'PRODUCT_LIST_WEIGHT':
       $lc_text = TABLE_HEADING_WEIGHT;
       $lc_align = 'right';
       break;
     case 'PRODUCT_LIST_IMAGE':
       $lc_text = TABLE_HEADING_IMAGE;
       $lc_align = 'center';
       break;
     case 'PRODUCT_LIST_BUY_NOW':
       $lc_text = TABLE_HEADING_BUY_NOW;
       $lc_align = 'center';
       break;
   }

//sort order
   if ($column_list[$col] == 'PRODUCT_LIST_SORT_ORDER'){break;}
   if ( ($column_list[$col] != 'PRODUCT_LIST_BUY_NOW') && ($column_list[$col] != 'PRODUCT_LIST_IMAGE') && ($column_list[$col] != 'PRODUCT_LIST_MULTIPLE') && ($column_list[$col] != 'PRODUCT_LIST_SHORT_DESCRIPTION')) {
   //if ( ($column_list[$col] != 'PRODUCT_LIST_BUY_NOW') && ($column_list[$col] != 'PRODUCT_LIST_IMAGE') && ($column_list[$col] != 'PRODUCT_LIST_SHORT_DESCRIPTION')) {
//end sort order
     $lc_text = tep_create_sort_heading($HTTP_GET_VARS['sort'], $col+1, $lc_text);
   }

   $list_box_contents[0][] = array('align' => $lc_align,
                                   'params' => 'class="productListing-heading"',
                                   'text' => ' ' . $lc_text . ' ');
 }


 if ($listing_split->number_of_rows > 0) {
   $rows = 0;
   $listing_query = tep_db_query($listing_split->sql_query);
   while ($listing = tep_db_fetch_array($listing_query)) {
     $rows++;

     if (($rows/2) == floor($rows/2)) {
       $list_box_contents[] = array('params' => 'class="productListing-even"');
     } else {
       $list_box_contents[] = array('params' => 'class="productListing-odd"');
     }

     $cur_row = sizeof($list_box_contents) - 1;

     for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
       $lc_align = '';

//sort order
       if ($column_list[$col] == 'PRODUCT_LIST_SORT_ORDER'){
         break;
       }
//end sort order

   if ((SHOW_PRICE_PER == 'Ja') && (isset($listing['products_price_per']))) {
    if (($listing['products_price_per']) >= '2'){
 	    $price_per = $listing['products_price_per'] . ' ' . TEXT_PRICE_PER;
     } else {
       if (($listing['products_price_per']) == '1') {
      $price_per = TEXT_PRICE_PER_PCS;
       } else {
      $price_per = '';
       }
     }
   }

       switch ($column_list[$col]) {
         case 'PRODUCT_LIST_MODEL':
           $lc_align = '';
           $lc_text = ' ' . $listing['products_model'] . ' ';
           break;
         case 'PRODUCT_LIST_PRICE_PER_PIECE':
           $lc_align = '';
           $lc_text = ' ' . $listing['products_price_per_piece'] . ' ';
           break;
         case 'PRODUCT_LIST_NOTES':
           $lc_align = '';
           $lc_text = ' ' . $listing['products_notes'] . ' ';
           break;
         case 'PRODUCT_LIST_NAME':
           $lc_align = '';
if (PRODUCT_LIST_COMBINE_NAME_DESCRIPTION == 'false') {
           if (isset($HTTP_GET_VARS['manufacturers_id'])) {
             $lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a>';
           } else {
             $lc_text = ' <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a> ';
           }
         } else {
           if (isset($HTTP_GET_VARS['manufacturers_id'])) {
             $lc_text = '<table width="100%" border="0" cellspacing="0" cellpadding="2" class="producktListName"><tr><td class="productListName"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a></td></tr><tr><td class="productListDescription">' . $listing['products_short_description'] . '</td></tr><tr><td class="productListMore" align="right"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '" class="productListDescription">' . READ_MORE . '</a></td></tr></table>';
           } else {
             $lc_text = '<table width="100%" border="0" cellspacing="0" cellpadding="2"><tr><td class="productListName"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a></td></tr><tr><td class="productListDescription">' . $listing['products_short_description'] . '</td></tr><tr><td class="productListMore" align="right"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '" class="productListDescription">' . READ_MORE . '</a></td></tr></table>';
           }
         }

           break;
         case 'PRODUCT_LIST_SHORT_DESCRIPTION':
           $lc_align = '';
           $lc_text = $listing['products_short_description'] . ' ';
           break;
         case 'PRODUCT_LIST_MANUFACTURER':
           $lc_align = '';
           $lc_text = ' <a href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $listing['manufacturers_id']) . '">' . $listing['manufacturers_name'] . '</a> ';
           break;
         case 'PRODUCT_LIST_PRICE':
           $lc_align = 'right';
if (PRODUCT_LIST_COMBINE_PRICE_BUY == 'false'){
           if (tep_not_null($listing['specials_new_products_price'])) {
             $lc_text = '<table border="0" cellspacing="0" cellpadding="0" class="productListPrice"><tr><td valign="top" align="right" class="productListSpecialPrice">' . $currencies->display_price($listing['specials_new_products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</td></tr><tr><td valign="top" class="productListNormalPrice">' . $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</td></tr></table>';
           } else {
             $lc_text = '<table border="0" cellspacing="0" cellpadding="0" class="productListPrice"><tr><td valign="top" align="right" class="productListPricePer">' . $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</td></tr></table>';
           }
         } else {
           if (tep_not_null($listing['specials_new_products_price'])) {
             $lc_text = '<table border="0" cellspacing="0" cellpadding="0" class="productListPrice"><tr><td align="right" class="productListPricePer">' . $price_per . '</td></tr><tr><td valign="top" align="right" class="productListSpecialPrice">' . $currencies->display_price($listing['specials_new_products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</td></tr><tr><td valign="top" align="right" class="productListNormalPrice">' .  $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</tr><tr><td align="right" class="productListBuyNow"><a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id']) . '">' . tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW) . '</a></td></tr></table>';
           } else {
             $lc_text = '<table border="0" cellspacing="0" cellpadding="0" class="productListPrice"><tr><td align="right" class="productListPricePer">' . $price_per . '</td></tr><tr><td valign="top" align="right" class="productListPrice">' . $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</td></tr><tr><td align="right" class="productListBuyNow"><a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id']) . '">' . tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW) . '</a></td></tr></table>';
           }
         }

           break;
         case 'PRODUCT_LIST_QUANTITY':
           $lc_align = 'right';
           $lc_text = ' ' . $listing['products_quantity'] . ' ';
           break;
         case 'PRODUCT_LIST_WEIGHT':
           $lc_align = 'right';
           $lc_text = ' ' . $listing['products_weight'] . ' ';
           break;
         case 'PRODUCT_LIST_IMAGE':
           $lc_align = 'center';
           if (isset($HTTP_GET_VARS['manufacturers_id'])) {
             $lc_text = '<table width="' . SMALL_IMAGE_WIDTH . '" border="0" cellspacing="0" cellpadding="2"><tr><td align="center" class="productListImage"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a></td></tr><tr><td align="center" ><a href="' . tep_href_link(DIR_WS_IMAGES . $listing['products_image']) . '" rel="lightbox" title="' . $listing['products_name'] . '" >' . CLICK_TO_ENLARGE . '</a></td></tr></table>';
           } else {
             $lc_text = '<table width="' . SMALL_IMAGE_WIDTH . '" border="0" cellspacing="0" cellpadding="2"><tr><td align="center" class="productListImage"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a></td></tr><tr><td align="center" ><a href="' . tep_href_link(DIR_WS_IMAGES . $listing['products_image']) . '" rel="lightbox" title="' . $listing['products_name'] . '" >' . CLICK_TO_ENLARGE . '</a></td></tr></table>';
           }
           break;
         case 'PRODUCT_LIST_BUY_NOW':
           $lc_align = 'center';
           $lc_text = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id']) . '">' . tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW) . '</a> ';
           break;
       }

       $list_box_contents[$cur_row][] = array('align' => $lc_align,
                                              'params' => 'class="productListing-data" valign="top"',
                                              'text'  => $lc_text);
     }
   }

   new productListingBox($list_box_contents);
 } else {
   $list_box_contents = array();

   $list_box_contents[0] = array('params' => 'class="productListing-odd" valign="top"');
   $list_box_contents[0][] = array('params' => 'valign="top"',
                                  'text' => TEXT_NO_PRODUCTS);

   new productListingBox($list_box_contents);
 }

 if ( ($listing_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '2') || (PREV_NEXT_BAR_LOCATION == '3')) ) {
?>
<table border="0" width="100%" cellspacing="0" cellpadding="3">
 <tr>
   <td class="smallText"><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></td>
   <td class="smallText" align="right"><?php echo TEXT_RESULT_PAGE . ' ' . $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></td>
 </tr>
</table>
<?php
 }
?>  

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...