Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Simple Search Box (Portable)


brett_ferguson

Recommended Posts

Okay, after a few days beating my head against my monitor I've collected and distilled what I believe is the most elegant and simplified search box for use in any area of your OSC site. I'm using a few contributions to work off, so all I've done is the cutting and pasting.

See the results here on my index page

<?php 
$hide = tep_hide_session_id(); 
echo '<form name="quick_find" method="get" action="' . tep_href_link (FILENAME_ADVANCED_SEARCH_RESULT, '', 'NONSSL', false) . '">'; 
echo $hide . '<input type="text" name="keywords" size="20" maxlength="30" value="' . BOX_SEARCH_TEXT . '"> ' .  '<input type="submit" value="Go"><br><a href="' . tep_href_link(FILENAME_ADVANCED_SEARCH) . '">' . BOX_SEARCH_ADVANCED_SEARCH . tep_draw_hidden_field('search_in_description', '1') . '</a>'; 
echo '</form>'; 
?>

  • This is NOT a standalone php file, but can be... I've put mine within my header.php file. It can also be added to most other files like the column_left.php and column_right.php, but you will need to remove the surrounding <?php and ?> tags.
  • It is a rework of code which Mattice contributed when someone else wanted to have a search box which didn't look like an infobox. So there is no surrounding infobox code (just stating the bloody obvious!) Hence: it looks only a little like the regular search box. No background and no borders!! Did I get that clear enough? :huh:
  • Lastly the hidden field which iiinetworks (Matt) suggested, was added to make the search look in the product fields as well as desriptions. So your users can type any word you may have used when you were writing up a product's entry, and they'll find what they're after.

Put the above code anywhere you need a simple search with just the input box and a go button. I've moved the word 'Search' into the input box so you don't need to waste any space nearby to tell your users what the box is for. They can simply highlight the text and type over it.

Thanks to Mattice, Matt (iinetworks) and Emerson for steering me to the right places, we eventually got there guys :rolleyes: Sorry you're dealing with such a dumbass.

 

This is the holy grail of simple search boxes for me, hope it's useful to others in the community.

Link to comment
Share on other sites

For future reference, posts like these are best put in the Tips & Tricks forum. That way people can find them without wading through all the questions first. I.e. some of us search the Tips & Tricks forum first because there are fewer duplicate posts, etc. in it. Also, it gives it a chance to be seen by more people. I have read all the new posts in the Tips & Tricks forum every time that I have signed on, while I skip the General Support, Installation & Configuration, and Contributions General Support whenever I'm pressed for time.

 

Hth,

Matt

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...