Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Removing an annoying bar


Guest

Recommended Posts

Posted

Hello all.

 

I'm having trouble just locating the code for a certain object in my *** site. The items in the menu down the side lead to pages with a sort of introduction for each product. Each of those pages, in turn, leads to a page for all things under that prdocut heading, and shopping cart options. Now, on that intermediate page is a blue bar, across the top. The bar is blue, and at different points along it has "Product Name", then "Price+", then "Buy Now". Which file/files can I find this in?

 

Thanks.

Posted

I want to know that too. Not because I want to get rid of it, but because I want to change the sorting. Judging by what you write yours sorts on price. Mine sorts on product name. But I want it sorted on Model. And I don't know either where to find it. :(

RojanUK

Posted

It's the joy of open source software. It has many great things to recommend it. Unfortunately, it's also put together by hundreds of people who've never met and really sorted things out, so it has 'every feature you'll never need', located in odd directory structures that not even Magellan could figure out.

Posted
It's the joy of open source software. It has many great things to recommend it. Unfortunately, it's also put together by hundreds of people who've never met and really sorted things out, so it has 'every feature you'll never need', located in odd directory structures that not even Magellan could figure out.

True, but the more you work with it, the more you discover and manage to solve by yourself I'm finding. I'm not familiar with PHP or SQL either and I've posted many question here, but I've solved a lot of things myself simply by reading a lot and looking through the files myself. Sometimes I find the answer to a question I posted here before anyone has a chance to answer. That's quite kewl. :rolleyes:

 

What annoys me a little bit about that is that, even though it's a great learning curve and you learn heaps and heaps of new information, it's taking so very long to teach yourself in effect, that you stand to lose money on your site which cannot go live until you're done. This is annoying for the people who build their own shop, but what to think about the people who build it for a client and have that client pounding on the door. Try explaining to him/her that it's open source software. *grin* :D

 

In this particular case I know - from looking at other live osCommerce shops, that sorting on model number is possible, even though the default seems to be product name, but I've looked high, low and somewhere in the middle and I cannot locate the file in which that is defined. And that, I think, is the same file you're after. So I hope there's someone here with the answer.

RojanUK

Posted

Doesn't matter, I found it and fixed it. It is line 82 to 87 of /httpdocs/includes/modules/product_listing.php.

Posted

If you're looking for it, the code looks like this:

 ? ? ?echo ' ?<tr>';
? ? ?echo ' ? ?<td width="10%" class="productListing-heading"> </td>';
? ? ?echo ' ? ?<td width="60%" align="center" class="productListing-heading"> ' . tep_create_sort_heading($HTTP_GET_VARS['sort'], 2, TABLE_HEADING_PRODUCTS) . ' </td>';
? ? ?echo ' ? ?<td width="15%" align="center" class="productListing-heading"> ' . tep_create_sort_heading($HTTP_GET_VARS['sort'], 3, TABLE_HEADING_PRICE) . ' </td>';
? ? ?echo ' ? ?<td width="15%" align="center" class="productListing-heading"> ' . TABLE_HEADING_BUY_NOW . ' </td>';
? ? ?echo ' ?</tr>';

But it's a lot neater when it isn't wrapped.

Posted

That didn't solve my problem unfortunately. In that file looking at PRODUCT_NAME there is actually no mention of ['sort'], which obviously means that I can't remove it and therefore the + sign will still be there... *growl*

RojanUK

Posted

I noticed a new problem with this sorting of the products.

 

Following the above tips I managed to have the listing sorted on p.products_model, rather than pd.products_name, which is the default setting. So far so good.

 

I also managed to find where I could change the fact that even though the listing was sorting on model there was still a '+' sign behind the product name header. I managed to remove that too. Again, so far so good.

 

Then I entered into admin/configuration/maximum values that I wanted a maximum of 10 products per page. That worked too, but that's when the problem started. When I go to the catagory and it displays the first 10 products in that catagory it's sorting on model number. When I then click on 'next' to go to the next page all the sorting gets muddled up. Therefore I'm actually not seeing the next product but one of the products of the first page. When I go back to the first page I notice that everything is muddled up - at first glance sorted on product name again.

 

Any ideas?

RojanUK

Posted
If you're looking for it, the code looks like this:

 ? ? ?echo ' ?<tr>';
? ? ?echo ' ? ?<td width="10%" class="productListing-heading"> </td>';
? ? ?echo ' ? ?<td width="60%" align="center" class="productListing-heading"> ' . tep_create_sort_heading($HTTP_GET_VARS['sort'], 2, TABLE_HEADING_PRODUCTS) . ' </td>';
? ? ?echo ' ? ?<td width="15%" align="center" class="productListing-heading"> ' . tep_create_sort_heading($HTTP_GET_VARS['sort'], 3, TABLE_HEADING_PRICE) . ' </td>';
? ? ?echo ' ? ?<td width="15%" align="center" class="productListing-heading"> ' . TABLE_HEADING_BUY_NOW . ' </td>';
? ? ?echo ' ?</tr>';

But it's a lot neater when it isn't wrapped.

By the way: This doesn't look anything like my catalog/includes/modules/product_listing.php, which is rather worrying.... :(

RojanUK

Posted

I'm adding my products to my site and I've just come across yet another catagory with more than 10 products in, so the above mentioned problem rears its head again.

 

Is there anyone who can help, please?

RojanUK

Posted

I've noticed many sites who are sorting on different fields than the product name. Surely someone must know how this is achieved. Please, I'm despirate....

 

Thanks!

RojanUK

Posted

The link to the next pages gives the variables for the sorting in the URL (&sort=3). This is what gives you the problem: you sort on model, but for the next pages the sorting order is on product name again.

 

I'm not familiar enough with the code of product_listing.php to be able to tell where to change that (try changing it by typing in the URL, you might at least find out which number to use.

Posted
The link to the next pages gives the variables for the sorting in the URL (&sort=3). This is what gives you the problem: you sort on model, but for the next pages the sorting order is on product name again.

 

I'm not familiar enough with the code of product_listing.php to be able to tell where to change that (try changing it by typing in the URL, you might at least find out which number to use.

I thought that too, but in the entire product_listing.php there is no mention of $sort= at all. OK, I'm going to paste the entire product_listing.php hoping that one of you brilliant people out there will be able to spot the problem. I do think that JanZ is basically correct in determining the error, but with the code being different to what was posted earlier and to what JanZ is suggesting I have no idea where to turn anymore. So here it is:

 

<?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
*/

 $listing_split = new splitPageResults($listing_sql, MAX_DISPLAY_SEARCH_RESULTS, 'p.products_id');

 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="2">
 <tr>
   <td class="smallText"><?php $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_NAME':
       $lc_text = TABLE_HEADING_PRODUCTS;
       $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;
   }

   if ( ($column_list[$col] != 'PRODUCT_LIST_BUY_NOW') && ($column_list[$col] != 'PRODUCT_LIST_IMAGE') ) {
     $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 = '';

       switch ($column_list[$col]) {
         case 'PRODUCT_LIST_MODEL':
           $lc_align = '';
           $lc_text = ' ' . $listing['products_model'] . ' ';
           break;
         case 'PRODUCT_LIST_NAME':
           $lc_align = '';
           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> ';
           }
           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 (tep_not_null($listing['specials_new_products_price'])) {
             $lc_text = ' <s>' .  $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</s>  <span class="productSpecialPrice">' . $currencies->display_price($listing['specials_new_products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</span> ';
           } else {
             $lc_text = ' ' . $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . ' ';
           }
           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 = '<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>';
           } else {
             $lc_text = ' <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> ';
           }
           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"',
                                              'text'  => $lc_text);
     }
   }

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

   $list_box_contents[0] = array('params' => 'class="productListing-odd"');
   $list_box_contents[0][] = array('params' => 'class="productListing-data"',
                                  '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="2">
 <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
 }
?>

 

That's my catalog/includes/modules/product_listing.php. I so hope someone will see the one thing that I've been overlooking...

 

Thanks.

RojanUK

Posted

Right. Thanks to the AutoSort contrib I've got it sorted now, but the catagory names are messed up now. In the catagory box I see now the URL's rather than the catagory name links. ARGH! :(

RojanUK

Posted

By the way: this is what it looks like:

 

catagories.jpg

 

Nice. B)

I've already checked both the catagories.php files but couldn't find a thing and I'm staring at them until I go blind... Any suggestions will be welcome as always...

RojanUK

Posted

I've been playing around with it and have found out that that problem is in catalog/includes/boxes/catagories.php. The moment you add the AutoSort Mod bit to the file as suggested in the contribution the catagory name structure muddles as depicted in the above picture. When I remove that piece of code again from the catagories.php file the structure returns to normal.

 

So even though it does do what it says on the tin, the side-effects are not worth it and I think it's safe to state that the AutoSort contribution does not work. Shame. Anyway, it's also created another little problem. I've removed the code from the files of course, but on the sub-catagory page a white box has appeared and I have no idea where that comes from.

 

whitebox.jpg

 

Plus the fact that obviously now I've removed the AutoSort code it won't perform it's primary function anymore and I'm back to square one: How can I sort on product model (field 2) instead of the default product name (field 3)?

 

I hope there is someone out there who can help me, because the more I try to do myself in this instance the more I screw up my site and I really can't afford that. (Oh yeah, I did back up, but found out that that was only the database and not the whole site... So by reversing the installation instructions of the contrib's I've tried to restore the site... Worked as well, apart from that mysterious white box)

RojanUK

Posted

Here's the current catalog/includes/boxes/catagories.php file:

 

<?php
/*
 $Id: categories.php,v 1.25 2003/07/09 01:13:58 hpdl Exp $

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

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

 function tep_show_category($counter) {
   global $tree, $categories_string, $cPath_array;

   for ($i=0; $i<$tree[$counter]['level']; $i++) {
     $categories_string .= "  ";
   }

   $categories_string .= '<a href="';

   if ($tree[$counter]['parent'] == 0) {
     $cPath_new = 'cPath=' . $counter;
   } else {
     $cPath_new = 'cPath=' . $tree[$counter]['path'];
   }
   
   $categories_string .= tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">';

   if (isset($cPath_array) && in_array($counter, $cPath_array)) {
     $categories_string .= '<b>';
   }

// display category name
   $categories_string .= $tree[$counter]['name'];

   if (isset($cPath_array) && in_array($counter, $cPath_array)) {
     $categories_string .= '</b>';
   }

   if (tep_has_category_subcategories($counter)) {
     $categories_string .= '';
   }

   $categories_string .= '</a>';

   if (SHOW_COUNTS == 'true') {
     $products_in_category = tep_count_products_in_category($counter);
     if ($products_in_category > 0) {
       $categories_string .= ' (' . $products_in_category . ')';
     }
   }

   $categories_string .= '<br>';

   if ($tree[$counter]['next_id'] != false) {
     tep_show_category($tree[$counter]['next_id']);
   }
 }
?>
<!-- categories //-->
         <tr>
           <td>
<?php
 $info_box_contents = array();
 $info_box_contents[] = array('text' => BOX_HEADING_CATEGORIES);

 new infoBoxHeading($info_box_contents, true, false);

 $categories_string = '';
 $tree = array();

 $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '0' and c.categories_id = cd.categories_id and cd.language_id='" . (int)$languages_id ."' order by sort_order, cd.categories_name");
 while ($categories = tep_db_fetch_array($categories_query))  {
   $tree[$categories['categories_id']] = array('name' => $categories['categories_name'],
                                               'parent' => $categories['parent_id'],
                                               'level' => 0,
                                               'path' => $categories['categories_id'],
                                               'next_id' => false);

   if (isset($parent_id)) {
     $tree[$parent_id]['next_id'] = $categories['categories_id'];
   }

   $parent_id = $categories['categories_id'];

   if (!isset($first_element)) {
     $first_element = $categories['categories_id'];
   }
 }

 //------------------------
 if (tep_not_null($cPath)) {
   $new_path = '';
   reset($cPath_array);
   while (list($key, $value) = each($cPath_array)) {
     unset($parent_id);
     unset($first_id);
     $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$value . "' and c.categories_id = cd.categories_id and cd.language_id='" . (int)$languages_id ."' order by sort_order, cd.categories_name");
     if (tep_db_num_rows($categories_query)) {
       $new_path .= $value;
       while ($row = tep_db_fetch_array($categories_query)) {
         $tree[$row['categories_id']] = array('name' => $row['categories_name'],
                                              'parent' => $row['parent_id'],
                                              'level' => $key+1,
                                              'path' => $new_path . '_' . $row['categories_id'],
                                              'next_id' => false);

         if (isset($parent_id)) {
           $tree[$parent_id]['next_id'] = $row['categories_id'];
         }

         $parent_id = $row['categories_id'];

         if (!isset($first_id)) {
           $first_id = $row['categories_id'];
         }

         $last_id = $row['categories_id'];
       }
       $tree[$last_id]['next_id'] = $tree[$value]['next_id'];
       $tree[$value]['next_id'] = $first_id;
       $new_path .= '_';
     } else {
       break;
     }
   }
 }
 tep_show_category($first_element); 

 $info_box_contents = array();
 $info_box_contents[] = array('text' => $categories_string);

 new infoBox($info_box_contents);
?>
           </td>
         </tr>
<!-- categories_eof //-->

RojanUK

Posted

The white box is gone. Found the problem. There was still AutoSort code in catalog/index.php, even though everything else related to AutoSort had already been removed.

 

So back to square one. Can anyone tell me how to sort the product listing on field 2 (product model) instead of the default field 3 (product name)? $sort=3 is nowhere to be seen in any of the files, so that's not it. I'm very open for suggestions guys.

RojanUK

Posted

I managed to get it sorting on product_model (at least for the first page of 10 products; it's set to not display more than 10 products per page) by this piece of code in catalog/index.php:

 

    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++) {
       if ($column_list[$i] == 'PRODUCT_LIST_NAME') {
         $HTTP_GET_VARS['sort'] = $i+1 . 'a';
         $listing_sql .= " order by p.products_model";
         break;
       }
     }

 

I changed the listing_sql from pd.products_name to p.products_model. That's it. And like I said it does sort right on page one, but as soon as you go to page to it reverts back to the default setting. What am I doing wrong?

RojanUK

Posted
The link to the next pages gives the variables for the sorting in the URL (&sort=3). This is what gives you the problem: you sort on model, but for the next pages the sorting order is on product name again.

 

I'm not familiar enough with the code of product_listing.php to be able to tell where to change that (try changing it by typing in the URL, you might at least find out which number to use.

Actually, this is more interesting than I thought. If I copy the link hiding behind the 'next page' link at the bottom of a product list it says:

 

http://127.0.0.1/home/catalog/index.php?cPath=26_36&sort=3a&page=2

 

There's the &sort=3 that I can't find in any file. Where does he get that from? osC creates this link automatically because I entered in admin/max values that he should display no more than 10 products per page. Which means that he gets his info from somewhere to create this automatic link. Hmmm...

RojanUK

Posted

It seems like I've finally cracked it! (Fingers crossed)

 

In catalog/index.php it says:

 

$HTTP_GET_VARS['sort'] = $i+1 . 'a';

 

which I've just changed to:

 

$HTTP_GET_VARS['sort'] = $i . 'a';

 

And it seems to work. I really hope so. So far it works like a charm, but if that changes I'll let you know.

 

By the way, whilst being on the subject of sorting on product model: Where exactly can I change the text echo 'Model' which appears above the column on the product listings? I'm using that field for the order number you see, so it would be better if it said: Order No.

 

Thanks again.

RojanUK

Posted

From you products_info.php post:

 

  <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>

 

What you want must be in "display_links" method of the $listing_split's class.

 

Maybe "sort" is language specific, which is why you won't find it, or maybe it is coded as

 

'sort' . '=a' . '&' . $sort_col

 

or something else that makes it hard to see.

 

I'd be of more help, but I haven't got my osCommerce site with me :-)

 

HTH

 

Quentin

Posted
By the way, whilst being on the subject of sorting on product model: Where exactly can I change the text echo 'Model' which appears above the column on the product listings? I'm using that field for the order number you see, so it would be better if it said: Order No.

And I just found that too... This feels pretty good... :D

RojanUK

Archived

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

×
×
  • Create New...