Jump to content
Sign in to follow this  
Bigredman74

[Contribution] - Search Box Anywhere

Recommended Posts

select count(distinct p.products_id) as total from (products p left join products_to_products_extra_fields p2pef on p.products_id=p2pef.products_id) left join manufacturers m on m.manufacturers_id=p.manufacturers_id, products_description pd left join specials s on p.products_id = s.products_id, categories c, products_to_categories p2c, products_description pd, categories c, products_to_categories p2c where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '1' and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and ((pd.products_name like '%huggies%' or p.products_model like '%huggies%' or m.manufacturers_name like '%huggies%' or p2pef.products_extra_fields_value like '%huggies%' or pd.products_description like '%huggies%') )
You have products_description pd in the query twice. Remove the second one and the two after it: ", products_description pd, categories c, products_to_categories p2c". If you can't figure it out from the code, you'll need to post the parts that refer to any of those three tables.

Always back up before making changes.

Share this post


Link to post
Share on other sites
Many questions about this contribution in STS but no good answers... :huh:

 

I run STS 4.5.8 but have failed to get this to work. All i see on my page is the frey search box with the code inside of it:

 

<?php echo tep_draw_form('search', tep_href_link(FILENAME_ADVANCED_SEARCH_RESULT, '', 'NONSSL', false), 'get') . tep_draw_hidden_field('search_in_description','1') . tep_draw_input_field('keywords', '', 'size="10" maxlength="30" style="width: ' . (BOX_WIDTH+10) . 'px"') . ' ' . tep_hide_session_id() .'<input type="submit" name="Submit" value="Search">' . '</form>'; ?>

 

Any ideas?

 

I'm running STS 4.5.8 as well and also have some issues. So far I did get just a text box + "search" button working. If I try to use an image I get a Fatal error: Call to a member function image_button() on a non-object in /includes/functions/html_output.php on line 129. It's definitely coming from the line that creates the search button.

 

For simplicity, I made a function and later call the function within my page template.

I put this function in my header, though I believe it can be anywehere as long as its before the function call.

For readability, I also split the echo into multiple lines.

  <?php
function print_search_bar($search_image_src)
{
	if ($search_image_src == '')
	{
		echo tep_draw_form('search', tep_href_link(FILENAME_ADVANCED_SEARCH_RESULT, '', 'NONSSL', false), 'get');
		echo tep_draw_hidden_field('search_in_description','1');
		echo tep_draw_input_field('keywords', '', 'size="10" maxlength="30" style="width: ' . (BOX_WIDTH+10) . 'px"') . ' ';
		echo tep_hide_session_id() .'<input type="submit" name="Submit" value="Search">' . '</form>';
	}
	else
	{
		// Error always happens if I uncomment either line below
		// Fatal error: Call to a member function image_button() on a non-object in /catalog/includes/functions/html_output.php on line 129

		echo tep_draw_form('search', tep_href_link(FILENAME_ADVANCED_SEARCH_RESULT, '', 'NONSSL', false), 'get');
		echo tep_draw_hidden_field('search_in_description','1');
		echo tep_draw_input_field('keywords', '', 'size="10" maxlength="30" style="width: ' . (BOX_WIDTH+10) . 'px"') . ' ';
		//echo tep_hide_session_id() .tep_image_submit('button_quick_find.gif', BOX_HEADING_ADVSEARCH, 'align="middle"')  . '</form>';
		//echo tep_image_submit('button_search.gif', BOX_HEADING_ADVSEARCH);
	}
}	
 ?>

 

Note that later in the code I call the function as so:

<?php print_search_bar(''); ?>

 

This function works perfectly if you call it as above, however, if you actually put in an image name it explodes with the fatal error.

Eventually, I plan to make it actually load the correct image, but as of now it just doesn't work.

I don't know if the issue is STS or that this code is just too outdated to work with OSC 2.2rc2a.

Note: the second commented line of code was pulled directly from search.php, which means it SHOULD work... you would think...

 

For reference, here is the html_output lines coresponding to the error:

////
// The HTML form submit button wrapper function
// Outputs a button in the selected language
 function tep_image_submit($image, $alt = '', $parameters = '') {
global $language;

	// START STS v4.4:
  global $sts;
	  $src = $sts->image_button($image,$language);   // this is the line producing the error
	  if ($src!='')
		$image_submit = '<input type="image" src="' . tep_output_string($src) . '" border="0" alt="' . tep_output_string($alt) . '"';
		else 
  // END STS v4.4
$image_submit = '<input type="image" src="' . tep_output_string(DIR_WS_LANGUAGES . $language . '/images/buttons/' . $image) . '" border="0" alt="' . tep_output_string($alt) . '"';

if (tep_not_null($alt)) $image_submit .= ' title=" ' . tep_output_string($alt) . ' "';

if (tep_not_null($parameters)) $image_submit .= ' ' . $parameters;

$image_submit .= '>';

return $image_submit;
 }

 

If anyone has any ideas on how to update the displaying of the search button image while using osc2.2rc2a + STS 4.5.8, it'd be much appreciated.

Share this post


Link to post
Share on other sites

Actually this doesn't work correctly as the search box floats around when the page size is changed. Please disregard my previous question as I will try another contribution.

 

Thanks

Sue

Share this post


Link to post
Share on other sites

hello!!

 

if i dnot want to put search string, and select a category,then press search button..it will show advanced_search. but i want it will display categorie's all product of selected category.

 

How this is possible?

 

Regards

Jaskaran

Share this post


Link to post
Share on other sites

Hello There i am a bit new here in the os commerce and just wanna know that how can i install the search module on the oscommerce 2.3 please reply me soon as possible i am really having trouble with it

Share this post


Link to post
Share on other sites

Hello There i am a bit new here in the os commerce and just wanna know that how can i install the search module on the oscommerce 2.3 please reply me soon as possible i am really having trouble with it

 

YES it would be nice a guide for v2.3.1 ....we still waiting for smart ppl to comes up :P

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×