Guest Posted July 19, 2003 Posted July 19, 2003 Hi Ive noticed that there are contributions to display just the catergories and not the sub-catergories and there is a contribution to put the catergories and sub-catergories in a drop down. But is it possible just to put the catergories in a drop down box :?: Thanks alot Matt
Daemonj Posted July 19, 2003 Posted July 19, 2003 Not that I am aware of. You should be able to copy the catalog/includes/boxes/manufacturers.php file and edit it to make your categories. ;) "Great spirits have always found violent opposition from mediocre minds. The latter cannot understand it when a man does not thoughtlessly submit to hereditary prejudices but honestly and courageously uses his intelligence." - A. Einstein
Guest Posted July 20, 2003 Posted July 20, 2003 <?php /* osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2001 osCommerce Released under the GNU General Public License */ ?> <!-- categories //--> <tr> <td> <?php $info_box_contents = array(); $info_box_contents[] = array('align' => 'left', 'text' => BOX_HEADING_CATEGORIES ); new infoBoxHeading($info_box_contents, true, false); $info_box_contents = array(); $info_box_contents[] = array('form' => '<form action="' . tep_href_link(FILENAME_DEFAULT) . '" method="get">' . tep_hide_session_id(), 'align' => 'left', 'text' => tep_draw_pull_down_menu('cPath', tep_get_categories(array(array('id' => '', 'text' => PULL_DOWN_DEFAULT))), $cPath, 'onchange="this.form.submit();"') ); new infoBox($info_box_contents); ?> </td> </tr> <!-- categories_eof //--> This is my code for a drop down box with catergories and sub-catergories in, is it not possible to slightly adapt this to display just the catergories :?: Thanks Matt
Daemonj Posted July 20, 2003 Posted July 20, 2003 I did not realize that you already something to do that. Remove the loop for the subcategories and you should have what you want. "Great spirits have always found violent opposition from mediocre minds. The latter cannot understand it when a man does not thoughtlessly submit to hereditary prejudices but honestly and courageously uses his intelligence." - A. Einstein
Guest Posted July 20, 2003 Posted July 20, 2003 which part of that code is the loop? Im sorry I only have basic php knowledge? Thanks Matt
Daemonj Posted July 20, 2003 Posted July 20, 2003 It is in the tep_get_categories() function in the catalog/includes/functions/general.php file. You would need to make a copy of it and remove the secondary while loop. "Great spirits have always found violent opposition from mediocre minds. The latter cannot understand it when a man does not thoughtlessly submit to hereditary prejudices but honestly and courageously uses his intelligence." - A. Einstein
Guest Posted July 20, 2003 Posted July 20, 2003 But... <?php /**************************************************************************** * $Id: top_categories.php,v 1.0 2003/04/90 14:34:00 clescuyer Exp $ * * Display only top categories * * osCommerce, Open Source E-Commerce Solutions * http://www.oscommerce.com/ * * Copyright (c) 2003 Go?lette * Christian Lescuyer <[email protected]> * http://www.goelette.net/ * * History: 1.0 Creation * * Released under the GNU General Public License ****************************************************************************/ ?> <!-- top_categories //--> <tr> <td> <?php ////////// // Display box heading ////////// $info_box_contents = array(); $info_box_contents[] = array('align' => 'left', 'text' => BOX_HEADING_CATEGORIES); new infoBoxHeading($info_box_contents, true, false); ////////// // Get categories list ////////// // Test for presence of status field for compatibility with older versions $status = tep_db_num_rows(tep_db_query('describe categories status')); $query = "select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = cd.categories_id and c.parent_id=0"; if ($status >0) $query.= " and c.status = '1'"; $query.= " and cd.language_id='" . $languages_id ."' order by sort_order, cd.categories_name"; $categories_query = tep_db_query($query); // Build categories string $categories_string = ''; while ($row = tep_db_fetch_array($categories_query)) { $categories_string .= '<a href="' . tep_href_link(FILENAME_DEFAULT, 'cPath=' . $row['categories_id']) . '">'; list($current) = explode('_', $HTTP_GET_VARS['cPath']); if ($row['categories_id'] == $current) $categories_string .= '<b>'; $categories_string .= $row['categories_name']; if ($row['categories_id'] == $current) $categories_string .= '</b>'; $categories_string .= '</a>'; $categories_string .= '<br>'; } ////////// // Display box contents ////////// $info_box_contents = array(); $info_box_contents[] = array('align' => 'left', 'text' => $categories_string); new infoBox($info_box_contents); ?> </td> </tr> <!-- top_categories_eof //--> This code just displays the top catergories without changing the functions, is there not an easy way to put this into a drop down box rather than a list :?: Thanks alot Matt
Daemonj Posted July 20, 2003 Posted July 20, 2003 Try changing ////////// // Display box contents ////////// $info_box_contents = array(); $info_box_contents[] = array('align' => 'left', 'text' => $categories_string); new infoBox($info_box_contents); to be ////////// // Display box contents ////////// $info_box_contents = array(); $info_box_contents[] = array('form' => tep_draw_form('categories', tep_href_link(FILENAME_DEFAULT, '', 'NONSSL', false), 'get'), 'text' => 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%"') . tep_hide_session_id()); and see if that does not do what you want. "Great spirits have always found violent opposition from mediocre minds. The latter cannot understand it when a man does not thoughtlessly submit to hereditary prejudices but honestly and courageously uses his intelligence." - A. Einstein
Guest Posted July 25, 2003 Posted July 25, 2003 Sorted the problem, if anyone would like to know how to do this, here is the code: <!-- drop_categories //--> <tr> <td> <?php /// Display box heading $info_box_contents = array(); $info_box_contents[] = array('align' => 'left', 'text' => BOX_HEADING_CATEGORIES); new infoBoxHeading($info_box_contents, true, false); /// Get categories list $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"); /// Display a dropdown $category_name_array = array(); $category_name_array[] = array('id' => '', 'text' => PULL_DOWN_DEFAULT); while ($categories = tep_db_fetch_array($categories_query)) { $categories_name = ((strlen($categories['categories_name']) > 20) ? substr($categories['categories_name'], 0, 20) . '..' : $categories['categories_name']); $category_name_array[] = array('id' => $categories['categories_id'], 'text' => $categories_name); } $info_box_contents = array(); $info_box_contents[] = array('form' => tep_draw_form('drop_down_nav', tep_href_link(FILENAME_DEFAULT, '', 'NONSSL', false), 'get'), 'text' => tep_draw_pull_down_menu('cPath', $category_name_array, (isset($HTTP_GET_VARS['cPath']) ? $HTTP_GET_VARS['cPath'] : ''), 'onChange="this.form.submit();" size="' . MAX_CATEGORIES_LIST . '" style="width: 100%"') . tep_hide_session_id()); new infoBox($info_box_contents); ?> </td> </tr> <!-- categories_eof //--> -Matt
Recommended Posts
Archived
This topic is now archived and is closed to further replies.