0

I know I've been asking a lot of questions lately, but there is so much I need to know and learn.

My question this time around is: How do I create a searchbar like this? Searchbar

You know, it being able to drop down and all. I've tried it in the past, but so far haven't been able to create a retractable searchbar. I've learned some javascript in the past, but either I am too rusty to get the job done or I just didn't learn about making retractable content like that.

1 Answer 1

0

This is a very broad question but I'll try and answer it anyway.

If this is not a learning exercise, I would recommend a plugin. Personally, I feel Mirasvit's Sphinx Search is very well written. You can learn from it and it does the job really well.

If this is a learning exercise then I recommend you spend some time improving your javascript through something like Codeschool.

In this instance, you would need a module with a controller to fire search terms at via ajax. The frontend javascript will observe the input box, and if more than 3 characters have been entered (or another suitable minimum) and another character is not entered within about 0.3 seconds, you should send off the current input to your newly created controller. The controller will return a json array of results for you to render on the frontend.

Magento actually has a built-in search, but it only lists previously searched terms, which is a bit rubbish imo. Might be good for reference though.

3
  • if this was a learning exercise, I'd love to do so. However since I'm basically "learning by working", I can't spend time doing exercises, sadly. I'll check Sphinx Search out. I've never previously used ajax, but I have realized that it's being used a lot, especially in search engines. edit: So that's why I didn't see it before. It's an extension to pay for. Guess I'll check its documentation.
    – theHubi
    Commented Oct 30, 2014 at 9:47
  • There are many implementations of Sphinx Search in Magento, take care that you find a good one. I recommended Mirasvit's but it's not free. Commented Oct 30, 2014 at 9:50
  • ok the documentation is pretty useless. I know how to install extensions and I can figure out how to configure them. Should I consider a "module creator" for this matter? I've seen Marius has coded one.
    – theHubi
    Commented Oct 30, 2014 at 9:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.