Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Drop Down Categories?


courtneyeliza

Recommended Posts

is there such thing?  :blink:

 

 

well, you need to steal a self-submitting dropdown box from the source code, manufacturers is a great choice. Fill it with the top categories or look for a mod where you have categories and subcategories in the dropdown already, and then strip it from the box (again by viewing the source code and rebuilding it). Then place it anywhere ...

:-)

Monika

 

addicted to writing code ... can't get enough of databases either, LOL!

 

my toolbox: Textpad - Compare and Merge - phpMyAdmin - WS_FTP - Photoshop - How to search the forum

 

Interactive Media Award July 2007 ~ category E-Commerce

my advice on the forum is for free, PMs where you send me work are considered consultation which I charge for ...

Link to comment
Share on other sites

I created a file called category_dd.php for the boxes folder...

but it doesnt work..can someone tell me what the issue is?

 

here it is...

 

<?php
/*
 $Id: categories.php,v 1.1.1.1 2004/03/04 23:40:40 ccwjr Exp $

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

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

 $categories_query = tep_db_query("select categories.categories_id from categories LEFT JOIN categories_description on categories.categories_id ORDER BY categories_description.categories_name");
 if ($number_of_rows = tep_db_num_rows($categories_query)) {
?>
<!-- categories //-->
<?php
   $boxHeading = '';
   $corner_left = 'square';
   $corner_right = 'square';

   if ($number_of_rows <= MAX_DISPLAY_categories_IN_A_LIST) {
// Display a list
     $boxContent = '';
     while ($categories = tep_db_fetch_array($categories_query)) {
       $categories_name = ((strlen($categories['categories_name']) > MAX_DISPLAY_MANUFACTURER_NAME_LEN) ? substr($categories['categories_name'], 0, MAX_DISPLAY_MANUFACTURER_NAME_LEN) . '..' : $categories['categories_name']);
       if (isset($HTTP_GET_VARS['categories_id']) && ($HTTP_GET_VARS['categories_id'] == $categories['categories_id'])) $categories_name = '<b>' . $categories_name .'</b>';
       $boxContent .= '<a href="' . tep_href_link(FILENAME_DEFAULT, 'categories_id=' . $categories['categories_id']) . '">' . $categories_name . '</a><br>';
     }

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

   } else {
// Display a drop-down
     $categories_array = array();
     if (MAX_categories_LIST < 2) {
       $categories_array[] = array('id' => '', 'text' => PULL_DOWN_DEFAULT);
     }

     while ($categories = tep_db_fetch_array($categories_query)) {
       $categories_name = ((strlen($categories['categories_name']) > MAX_DISPLAY_MANUFACTURER_NAME_LEN) ? substr($categories['categories_name'], 0, MAX_DISPLAY_MANUFACTURER_NAME_LEN) . '..' : $categories['categories_name']);
       $categories_array[] = array('id' => $categories['categories_id'],
                                      'text' => $categories_name);
     }

     $boxContent = tep_draw_form('categories', tep_href_link(FILENAME_DEFAULT, '', 'NONSSL', false), 'get');
     $boxContent .= tep_draw_pull_down_menu('categories_id', $categories_array, (isset($HTTP_GET_VARS['categories_id']) ? $HTTP_GET_VARS['categories_id'] : ''), 'onChange="this.form.submit();" size="' . MAX_categories_LIST . '" style="width: 100%"');
     $boxContent .= tep_hide_session_id();
  $boxContent .= '</form>';
   }

  //new infoBox($info_box_contents, $column_location, 0, 0);
?>
<!-- categories_eof //-->
<?php
 }
?>

Link to comment
Share on other sites

CLEANED IT UP A LITTLE

 

<?php
/*
 $Id: categories.php,v 1.1.1.1 2004/03/04 23:40:40 ccwjr Exp $

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

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

 $categories_query = tep_db_query("select * from categories NATURAL JOIN categories_description ORDER BY categories_name");
 if ($number_of_rows = tep_db_num_rows($categories_query)) {
?>
<!-- categories //-->
<?php
   $boxHeading = '';
   $corner_left = 'square';
   $corner_right = 'square';

   if ($number_of_rows <= MAX_DISPLAY_MANUFACTURERS_IN_A_LIST) {
// Display a list
     $boxContent = '';
     while ($categories = tep_db_fetch_array($categories_query)) {
       $categories_name = ((strlen($categories['categories_name']) > MAX_DISPLAY_MANUFACTURER_NAME_LEN) ? substr($categories['categories_name'], 0, MAX_DISPLAY_MANUFACTURER_NAME_LEN) . '..' : $categories['categories_name']);
       if (isset($HTTP_GET_VARS['categories_id']) && ($HTTP_GET_VARS['categories_id'] == $categories['categories_id'])) $categories_name = '<b>' . $categories_name .'</b>';
       $boxContent .= '<a href="' . tep_href_link(FILENAME_DEFAULT, 'categories_id=' . $categories['categories_id']) . '">' . $categories_name . '</a><br>';
     }

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

   } else {
// Display a drop-down
     $categories_array = array();
     if (MAX_categories_LIST < 2) {
       $categories_array[] = array('id' => '', 'text' => PULL_DOWN_DEFAULT);
     }

     while ($categories = tep_db_fetch_array($categories_query)) {
       $categories_name = ((strlen($categories['categories_name']) > MAX_DISPLAY_MANUFACTURER_NAME_LEN) ? substr($categories['categories_name'], 0, MAX_DISPLAY_MANUFACTURER_NAME_LEN) . '..' : $categories['categories_name']);
       $categories_array[] = array('id' => $categories['categories_id'],
                                      'text' => $categories_name);
     }

     $boxContent = tep_draw_form('categories', tep_href_link(FILENAME_DEFAULT, '', 'NONSSL', false), 'get');
     $boxContent .= tep_draw_pull_down_menu('categories_id', $categories_array, (isset($HTTP_GET_VARS['categories_id']) ? $HTTP_GET_VARS['categories_id'] : ''), 'onChange="this.form.submit();" size="' . MAX_MANUFACTURERS_LIST . '" style="width: 100%"');
     $boxContent .= tep_hide_session_id();
  $boxContent .= '</form>';
   }

  //new infoBox($info_box_contents, $column_location, 0, 0);
?>
<!-- categories_eof //-->
<?php
 }
?>

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...