Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Advanced Search Info Box


matthew_scullion

Recommended Posts

Advanced Search Infobox

 

Hi.

 

I have downloaded and installed the Advanced Search Infobox contribution and it works great. Unfortunately, it shows all the categories in my site, which makes the drop-down box very wide and very long which makes it hard to use and also ruins the layout of my page.

 

What I would ideally like to do is just have it showing the top level categories in the drop down, which would be fine. I would also need to be able to specify the width of the drop down box.

 

Does anyone know how to do this?

 

The code in the advanced infobox is as follows:

 

<!-- search //-->
	  <tr>
		<td>
<?php
 $info_box_contents = array();
 $info_box_contents[] = array('text' => BOX_HEADING_ADVSEARCH);

 new infoBoxHeading($info_box_contents, false, false);

 $info_box_contents = array();
 $info_box_contents[] = array('form' => tep_draw_form('advanced_search', tep_href_link(FILENAME_ADVANCED_SEARCH_RESULT, '', 'NONSSL', false), 'get'),
						   'text' => '<table border="0" width="100%" cellspacing="0" cellpadding="1"><tr><td class="infoBoxContents" valign="top" colspan="3">' . BOX_ADVSEARCH_KW . '</td></tr><tr><td class="infoBoxContents" valign="top" colspan="3">' . tep_draw_hidden_field('search_in_description','1') . tep_draw_input_field('keywords', '', 'size="15" maxlength="30" style="width: ' . (BOX_WIDTH-30) . 'px"') . tep_image_submit('button_quick_find.gif', BOX_HEADING_ADVSEARCH) . '</td></tr><tr><td class="infoBoxContents" valign="top" colspan="3">' . BOX_ADVSEARCH_PRICERANGE . '</td></tr><tr><td class="infoBoxContents" valign="top" colspan="3">' . tep_draw_input_field('pfrom','','size="4" maxlength="8"') . BOX_ADVSEARCH_PRICESEP . tep_draw_input_field('pto','','size="4" maxlength="8"') . '</td></tr><tr><td class="infoBoxContents" valign="top" colspan="3">' . BOX_ADVSEARCH_CAT . '</td></tr><tr><td class="infoBoxContents" valign="top" colspan="3">' . tep_draw_pull_down_menu('categories_id', tep_get_categories(array(array('id' => '', 'text' => BOX_ADVSEARCH_ALLCAT)))) . '</td></tr></table>');

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

 

Please bear in mind that I am a PHP novice and so will need an example if I need to make a code change.

 

Many thanks for any help in advance!

 

Regards,

 

Matthew

Link to comment
Share on other sites

for the top categories one way to do that is to create another function to return just those categories without parent. So in your catalog\includes\functions\general.php add the following function:

 

  function tep_get_top_categories($categories_array = '') {
global $languages_id;

if (!is_array($categories_array)) $categories_array = array();

$categories_query = tep_db_query("select c.categories_id, cd.categories_name from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where 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)) {
  $categories_array[] = array('id' => $categories['categories_id'],
							  'text' => $categories['categories_name']);
  }
}

return $categories_array;
 }

 

then modify the code you posted where it reads tep_get_categories to tep_get_top_categories and try it. Backup your files before modifying anything though.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...