Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Product Listing Column Sorting


Recommended Posts

I have been using a product_listing_col.php instead of the rows listing and I like it's look but I recently noticed that you cannot sort by price or stock. With the regular product_listing.php module you get a header with sort option.

 

I want to create a dropdown menu with sort options but I am having an impossible time trying to create a tep_draw_drop_down_menu with the proper array. My array is always empty. I havent written an array from scratch and all my attempts using examples from php.net still create an empty drop down list.

 

Can someone give me a hand on this one?

 

Here is the original contrib I am using.

 

http://www.oscommerce.com/community/contributions,112

Link to comment
Share on other sites

Here is what I have but it just uses the first letter. I know I am not even close to getting this correct.

 

 <tr>
  <td>
<?php
$sort = array(
    'price',
    'date',
    'name',
);
echo tep_draw_pull_down_menu('sort', $sort,'','');

?>
  </td>
</tr>

Link to comment
Share on other sites

OK well this is what I have that's working now as a drop down menu.

 

 <tr>
  <td>
<?php

echo tep_draw_pull_down_menu('sort', array(array('id' => 'ALA', 'text' => 'ALA'), array('id' => 'Price', 'text' => 'Sort by Price')), 'Price'); ?>
  </td>
</tr>

 

the problem is that I am unable to get it to submit onchange. Do I have to create a tep_draw_form?

Link to comment
Share on other sites

My latest attempt is much better:

 

 <tr>
  <td>

<?php
   echo tep_draw_form('sort', '', 'post');

     echo tep_draw_pull_down_menu('sort', array(array('id' => '3a', 'text' => 'Name'), array('id' => '4d', 'text' => 'Sort by Price')), '', 'onchange="this.form.submit()"');

?>
 </form>
  </td>
</tr>

 

While this now submits the page doesnt actually work. I have the sort options correct as 3a and 4d to try to force results but neither seems to take. Hmm..any new ideas? Once this is fixed up some it can be added to the contrib so that others who use column display can have more sort options.

Link to comment
Share on other sites

That's not working for me.

 

I am on MS1...

 

I keep getting really close but there is always something not working right.

 

This is the closest I got now.

 echo '<tr><td>';
      $sort_array = array();
$sort_array = array();
      $sort_array[] = array('id' => '4a', 'text' => 'Product Name Ascending');
      $sort_array[] = array('id' => '4d', 'text' => 'Product Name Descending');
      $sort_array[] = array('id' => '3a', 'text' => 'Product Price Ascending');
      $sort_array[] = array('id' => '3d', 'text' => 'Product Price Descending');

  echo tep_draw_form('sort', '', 'post');

   echo tep_draw_pull_down_menu('sort', $sort_array, (isset($HTTP_GET_VARS['sort']) ? $HTTP_GET_VARS['sort'] : ''), 'onChange="this.form.submit();"');


echo '</form></td></tr>';

 

I added this to my index.php but I am using SEF urls.

 

So lets say I am here: http://www.videogamedeals.com/index.php/so...th/87_19/page/2

 

Well when I make a change it makes the url this:

http://www.videogamedeals.com/index.php/so.../page/2?sort=4d

 

As you can see it quickly starts to make a mess of the url. So does anyone know how I might correct this?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...