Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Drop Down Product List?


bsnmcahi

Recommended Posts

Hi I want to list all the products in my catalog in a drop down box exactly like the manufacturers are! I have the code which I think needs to be edited but I cant do it, I have tried to change it to call the data from the product fields in the database but it causes errors!

 

can anybody help me in coding a drop down box listing all products by the name?

 

 

Original manufacturers drop down box code:

 

<?php

 

$manufacturers_query = tep_db_query("select manufacturers_id, manufacturers_name from " . TABLE_MANUFACTURERS . " order by manufacturers_name");

if ($number_of_rows = tep_db_num_rows($manufacturers_query)) {

?>

<div class="topbrandbox"><?php

 

if ($number_of_rows <= MAX_DISPLAY_MANUFACTURERS_IN_A_LIST) {

// Display a list

$manufacturers_list = '';

while ($manufacturers = tep_db_fetch_array($manufacturers_query)) {

$manufacturers_name = ((strlen($manufacturers['manufacturers_name']) > MAX_DISPLAY_MANUFACTURER_NAME_LEN) ? substr($manufacturers['manufacturers_name'], 0, MAX_DISPLAY_MANUFACTURER_NAME_LEN) . '..' : $manufacturers['manufacturers_name']);

if (isset($HTTP_GET_VARS['manufacturers_id']) && ($HTTP_GET_VARS['manufacturers_id'] == $manufacturers['manufacturers_id'])) $manufacturers_name = '<b>' . $manufacturers_name .'</b>';

$manufacturers_list .= '<a href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $manufacturers['manufacturers_id']) . '">' . $manufacturers_name . '</a>';

}

 

$manufacturers_list = substr($manufacturers_list, 0, -4);

 

$info_box_contents = array();

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

} else {

// Display a drop-down

$manufacturers_array = array();

if (MAX_MANUFACTURERS_LIST < 2) {

$manufacturers_array[] = array('id' => '', 'text' => PULL_DOWN_DEFAULT);

}

 

while ($manufacturers = tep_db_fetch_array($manufacturers_query)) {

$manufacturers_name = ((strlen($manufacturers['manufacturers_name']) > MAX_DISPLAY_MANUFACTURER_NAME_LEN) ? substr($manufacturers['manufacturers_name'], 0, MAX_DISPLAY_MANUFACTURER_NAME_LEN) . '..' : $manufacturers['manufacturers_name']);

$manufacturers_array[] = array('id' => $manufacturers['manufacturers_id'],

'text' => $manufacturers_name);

}

 

$info_box_contents = array();

$info_box_contents[] = array('form' => tep_draw_form('manufacturers', tep_href_link(FILENAME_DEFAULT, '', 'NONSSL', false), 'get'),

'text' => tep_draw_pull_down_menu('manufacturers_id', $manufacturers_array, (isset($HTTP_GET_VARS['manufacturers_id']) ? $HTTP_GET_VARS['manufacturers_id'] : ''), 'onChange="this.form.submit();" size="' . MAX_MANUFACTURERS_LIST . '" style="width: 140"') . tep_hide_session_id());

}

 

new infoBox($info_box_contents);

?></div>

<!-- manufacturers_eof //-->

<?php

}

?>

 

 

 

Thanks Martin!

Link to comment
Share on other sites

Does nobody have any idea how to make a dropdown list of all the products on the site, Ive found a contribution which does for a indivudual catogory but not he whole lot, want to put the box in my header section.

 

Martin

Link to comment
Share on other sites

I'm looking for the same thing. The closest I have found is http://www.oscommerce.com/community/contributions,2848, but it opens a pop-up and I don't want that, and I am not accomplished enough to adapt the code for my purposes

 

If I find what we're looking for I'll post here. It must be there somewhere, but having searched for hours, I am beginning to feel like Frodo in the Two Towers.

Link to comment
Share on other sites

There is a contribution that will put all of the products for whatever category you are in into a drop down menu. It should be able to be modified to show all of the products.

Wendy James

 

Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...