Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

How does this search function work.....


Mediajuggle

Recommended Posts

Just what fields does the search feature in oscommerce look for?

I've added a teddy bear to the site....

 

i've created the following keywords

 

teddy bear, stuffed animal, stuffed animals, teddy bears, teddy, bear, stuffed, animal, animals

 

and included it as a non viewable html comment in the description and as keywords and the search still wouldn't show a teddy bear when I typed in "teddy bears"

 

I think added the html comment to the title and it showed up during a search but when you click on the thumbnail on the search page, there was no image... and i found that I wasn't able to edit it in the backend so I had to delete the whole category....

 

does anyone know just how this search, searchesssss?

My Contribution

Music Download Store Template

http://www.oscommerce.com/community/contributions,4275

Link to comment
Share on other sites

I believe that it only searches the product name by default. I have seen a modification that adds searching in the product description as well. I don't know of any way to make it search header tags or comments, but there may well be such a mod.

 

If you are interested in the description search, please post here and I'll go dig it up.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

OK, I got my development system put back together and found the mod. Just change this line in includes/boxes/search.php

'text' => tep_draw_input_field('keywords', '', 'size="10" maxlength="30" style="width: ' . (BOX_WIDTH-30) . 'px"') . ' ' . tep_hide_session_id() . tep_image_submit('button_quick_find.gif', BOX_HEADING_SEARCH) . '<br>' . BOX_SEARCH_TEXT . '<br><a href="' . tep_href_link(FILENAME_ADVANCED_SEARCH) . '"><b>' . BOX_SEARCH_ADVANCED_SEARCH . '</b></a>');

to this

'text' => tep_draw_input_field('keywords', '', 'size="10" maxlength="30" style="width: ' . (BOX_WIDTH-30) . 'px"') . ' ' . tep_hide_session_id() . tep_draw_hidden_field('search_in_description', '1') . tep_image_submit('button_quick_find.gif', BOX_HEADING_SEARCH) . '<br>' . BOX_SEARCH_TEXT . '<br><a href="' . tep_href_link(FILENAME_ADVANCED_SEARCH) . '"><b>' . BOX_SEARCH_ADVANCED_SEARCH . '</b></a>');

 

I wonder how many other goodies like this are hidden in the code? Guess I need to go look.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

okay....

 

slight problem...

 

i've modified my code to look like this....

 

<?php

 $info_box_contents[] = array('form'  => '<form name="quick_find" method="get" action="' . tep_href_link(FILENAME_ADVANCED_SEARCH_RESULT, '', 'NONSSL', false) . '">',
                              'align' => 'left',
                              'text'  => $hide . '<input type="text" name="keywords" size="30" maxlength="30" value="" border="0" style="BACKGROUND-COLOR: #AFC1AD; COLOR: #000000; FONT-FAMILY: verdana, Helvetica; FONT-SIZE: 9px' . htmlspecialchars(StripSlashes(@$HTTP_GET_VARS["keywords"])) . '" style="width: ' . (BOX_WIDTH-150) . 'px"> ' . '</td><td align="left" valign="middle">' . tep_image_submit('search.gif', BOX_HEADING_SEARCH) . '<br>'
                             );
 new infoBox($info_box_contents);
?>
</td>

 

 

how do I modify this?

My Contribution

Music Download Store Template

http://www.oscommerce.com/community/contributions,4275

Link to comment
Share on other sites

Interesting. All of the stylesheet information makes it a bit hard to read. Nonetheless this shouldn't be too hard. We just need to add this part:

tep_draw_hidden_field('search_in_description', '1') .

 

somewhere in the middle. It adds in a hidden field so it doesn't much matter where we put it, as long as it's not inside another field or something like that. Try this:

              'text'  => $hide . '<input type="text" name="keywords" size="30" maxlength="30" value="" border="0" style="BACKGROUND-COLOR: #AFC1AD; COLOR: #000000; FONT-FAMILY: verdana, Helvetica; FONT-SIZE: 9px' . htmlspecialchars(StripSlashes(@$HTTP_GET_VARS["keywords"])) . '" style="width: ' . (BOX_WIDTH-150) . 'px"> ' . tep_draw_hidden_field('search_in_description', '1') . '</td><td align="left" valign="middle">' . tep_image_submit('search.gif', BOX_HEADING_SEARCH) . '<br>'

 

I've been looking through the search code. It is also possible to make it search Manufacturers, or just about any product database field for that matter. It would be fairly easy to turn these on or off through the Admin panel. Maybe I should turn this into a contribution. Or maybe I just need more sleep. :rolleyes:

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

OK, a bit of clarification here. After looking at the code, it seems that Simple Search looks at the Products Name, Model, and Manufacturer by default. Search in description, by price range, and by date range are options -- basically everything in the Advanced Search page. I wonder if it would be worth adding these options to the Admin panel....

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

Did you replace the existing line beginning with

'text' => $hide .
? I also need to know what version of osC you are running, since this doesn't look like MS2.

 

Rgards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

Question... usually before I make modifications...

I rename the original file so that I'll have it if I need to revert back to the original....

 

but i forgot to do this in this instance....

and even after copying and pasting the original code I posted from this board...

 

i can't even seem to get this back up now...

 

 

does copying from this board add hidden characters that would change the way the php interpets the script?

My Contribution

Music Download Store Template

http://www.oscommerce.com/community/contributions,4275

Link to comment
Share on other sites

okay forget the backup thing... I DID BACK IT UP.... at least to my modification

 

here is the complete code for my search...

 

<?php
/*
 $Id: search.php,v 1.1.1.1 2002/11/28 23:22:25 wilt Exp $

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

 Copyright (c) 2001 osCommerce

 Released under the GNU General Public License
*/
?>
<!-- search //-->

 <table width="320" border="0" cellspacing="2" cellpadding="0">
	 <tr>
   <td align="left" valign="middle">


<?php

 $info_box_contents[] = array('form'  => '<form name="quick_find" method="get" action="' . tep_href_link(FILENAME_ADVANCED_SEARCH_RESULT, '', 'NONSSL', false) . '">',
                              'align' => 'left',
                              'text'  => $hide . '<input type="text" name="keywords" size="30" maxlength="30" value="" border="0" style="BACKGROUND-COLOR: #AFC1AD; COLOR: #000000; FONT-FAMILY: verdana, Helvetica; FONT-SIZE: 9px' . htmlspecialchars(StripSlashes(@$HTTP_GET_VARS["keywords"])) . '" style="width: ' . (BOX_WIDTH-150) . 'px"> ' . '</td><td align="left" valign="middle">' . tep_image_submit('search.gif', BOX_HEADING_SEARCH) . '<br>'
                             );
 new infoBox($info_box_contents);
?>
</td>
   <td>
  	 <div align="center">
     <font size="1" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular"><small><a href="http://www.finasboutique.com/catalog/advanced_search.php">advanced <br>
       search</small></a></font></div>
   </td>
	 </tr>
 </table>
<!-- search_eof //-->

My Contribution

Music Download Store Template

http://www.oscommerce.com/community/contributions,4275

Link to comment
Share on other sites

IT"S WORKING!!!!!! THANX....

 

when I copied and pasted it... it didn't work.....

but when I typed it in....

 

it work's like a charm!! thanx....

 

and yes.. this would make a great mod......

My Contribution

Music Download Store Template

http://www.oscommerce.com/community/contributions,4275

Link to comment
Share on other sites

I didn't know about any problems with copy and paste from the board, but I have heard of this happening with some other programs. That's a good thing to remember.

 

Glad to hear you got it working. And I will submit this as a contribution as soon as I have some time.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...