advanced search by type ahead

Open to all! Ask other shopowners for help.
User avatar
zipurman
Builder
Posts: 540
Joined: Tue Oct 13, 2020 5:20 pm
Phoenix Version: v
Has thanked: 93 times
Been thanked: 162 times

Re: advanced search by type ahead

Post by zipurman »

Omar_one wrote: Fri Jan 20, 2023 7:28 am On the first post on this typic there is a link ..
We had it on 1.0.8.16 , but it's not enabled now..but I can enable it, if you would like a look
If you enable it, I'll have a look. I did manage to get a copy of the code but it's old. There is a lot of code for something as simple as a product search type-ahead ... so I'd be interested in seeing all it can do.
zipurman
-----------


Join The Code Co-op to get access to your library in the Code Co-op Forum
Omar_one
Senior Contributor
Posts: 677
Joined: Fri Oct 25, 2019 5:06 pm
Phoenix Version: v1.0.8.16
Has thanked: 100 times
Been thanked: 56 times

Re: advanced search by type ahead

Post by Omar_one »

zipurman wrote: Fri Jan 20, 2023 4:58 pm
Omar_one wrote: Fri Jan 20, 2023 7:28 am On the first post on this typic there is a link ..
We had it on 1.0.8.16 , but it's not enabled now..but I can enable it, if you would like a look
If you enable it, I'll have a look. I did manage to get a copy of the code but it's old. There is a lot of code for something as simple as a product search type-ahead ... so I'd be interested in seeing all it can do.
you can check it out
User avatar
zipurman
Builder
Posts: 540
Joined: Tue Oct 13, 2020 5:20 pm
Phoenix Version: v
Has thanked: 93 times
Been thanked: 162 times

Re: advanced search by type ahead

Post by zipurman »

Thanks Omar and all who have PM'd me.

I will have a look at the code and get this working on latest Phoenix next week.
zipurman
-----------
User avatar
zipurman
Builder
Posts: 540
Joined: Tue Oct 13, 2020 5:20 pm
Phoenix Version: v
Has thanked: 93 times
Been thanked: 162 times

Re: advanced search by type ahead

Post by zipurman »

I have started a re-code of the type-ahead here: https://phoenixaddons.com/demostore/

Currently it's a single hook of 300 lines. I plan on expanding it into a mod so it can be configured. What settings do you feel would be needed? I am releasing this one as a free mod, so any input is appreciated.

Zip
zipurman
-----------
User avatar
burt
Core Team
Posts: 4551
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 252 times
Been thanked: 412 times

Re: advanced search by type ahead

Post by burt »

@zipurman I dont know if this one does it, but I always thought it would be cool to sort the returned result by the position of the search string, eg;

canada
france
andorra
afghanistan

Let's say that the typeahead was "an"

the result would be

andorra
canada
france
afghanistan

I did have some effort at doing this a few years ago, but never really took it forward to somehting useful, here's the code I played with;

Code: Select all

SELECT 
  products_id, 
  products_name, 
  position("an" in products_name) as pos 
FROM 
  products_description
WHERE 
  products_name like '%an%'
ORDER BY pos
I am not here to build for you.
I am here to build with you. Let's help each other.
User avatar
zipurman
Builder
Posts: 540
Joined: Tue Oct 13, 2020 5:20 pm
Phoenix Version: v
Has thanked: 93 times
Been thanked: 162 times

Re: advanced search by type ahead

Post by zipurman »

burt wrote: Thu Jan 26, 2023 9:25 am @zipurman I dont know if this one does it, but I always thought it would be cool to sort the returned result by the position of the search string, eg ...
@burt thanks for the idea. I am matching several fields and also replacing spaces with % to allow wider matching. I love the idea and will do some logic to do what you suggest post SQL as I am already looping the data prior to showing it. Thanks for the idea! :)
zipurman
-----------
User avatar
zipurman
Builder
Posts: 540
Joined: Tue Oct 13, 2020 5:20 pm
Phoenix Version: v
Has thanked: 93 times
Been thanked: 162 times

Re: advanced search by type ahead

Post by zipurman »

I have added some more functionality, use the link above to preview.

- Type-ahead suggestion if searching name or model
- Some style updates
- sorting by relevance as well as type ahead offering best match
- loose focus closes dropdown
- regain focus pops open dropdown if search is not empty
- retain upper/lower on highlights
- remove html from result to avoid highlights breaking code
- remove html from search matching (searching for strong etc)

Still a single hook file. Will move to a mod once I get it so all required features are covered. Haven't had much feedback ...
zipurman
-----------
User avatar
Kofod95
Senior Contributor
Posts: 748
Joined: Sat Feb 06, 2021 7:38 pm
Phoenix Version: 1.0.8.20
Has thanked: 99 times
Been thanked: 179 times

Re: advanced search by type ahead

Post by Kofod95 »

Looks good!

A suggestion could be to make it possible to include categories in the results. Potentially also info pages, but I don't know if that would be slowing things down too much and require a modularized adcanced_search_results (similar to the fuzzy-search supporters code) with modules to show these alternative hits.

//Daniel
I'm not smart, but sometimes even a blind chicken can find a corn.
Here are a lot of corns: Phoenix user guide
heatherbell
Senior Contributor
Posts: 2540
Joined: Mon Oct 07, 2019 4:39 am
Phoenix Version:
Has thanked: 35 times
Been thanked: 243 times

Re: advanced search by type ahead

Post by heatherbell »

zipurman wrote: Fri Jan 27, 2023 8:56 pm use the link above to preview
Kofod95 wrote: Fri Jan 27, 2023 9:37 pm Looks good!
also info pages,
Certainly looks and behaves well with some very cool features.
We would second the suggestion for including search to Categories Title/Categories Description and InfoPages Text.
User avatar
tessthepup
Certified Developer
Posts: 382
Joined: Mon Mar 01, 2021 5:55 pm
Phoenix Version:
Has thanked: 47 times
Been thanked: 62 times

Re: advanced search by type ahead

Post by tessthepup »

heatherbell wrote: Sat Jan 28, 2023 7:58 am
zipurman wrote: Fri Jan 27, 2023 8:56 pm use the link above to preview
Kofod95 wrote: Fri Jan 27, 2023 9:37 pm Looks good!
also info pages,
Certainly looks and behaves well with some very cool features.
We would second the suggestion for including search to Categories Title/Categories Description and InfoPages Text.
@zipurman
Hi Preston, I echo everything said above but from a pure aesthetic point of view either give the option of showing 'show all results' & 'advanced search top or bottom of the results.

I personally would have those links at the bottom so not to distract from the products.


Join The Code Co-op to get access to your library in the Code Co-op Forum
Post Reply