Jump to content

PageAutocomplete with curated results?


neosin
 Share

Recommended Posts

what would be the best way to use PageAutocomplete and have some curated results above the search result?

For example a user searches for something and in the autocomplete list it shows results related to the search but also you could have a trigger to match some keyword and it will show at the top of the autocomplete results. How would this work in PW?

The way to do it I think (again with my limited PW knowledge) would be to have a hidden page with children as "search triggers" and if there is a match of the user search then show the related child trigger pages at the top of the autocomplete. How do I hook into the autocomplete? Is there a hook for comparing the search term to a hidden pages children?

thanks in advance & happy Easter weekend to all

Link to comment
Share on other sites

Haven't tested but from what I read from the core files, is that InputfieldAutocomplete uses ProcessPageSearch to look for the pages matching the fields options.


You could hook into the executeFor() method on ProcessPageSearch and replace the returned output with another list rendering of your own mix of pages, the ones found by the module, and the ones you define as curated at the beginning of the rendered list. I'd even bet you could add some CSS classes to make them look different.

 

 

  • Like 1
Link to comment
Share on other sites

Depending on your use case, here's two other options

  1. Clone PageAutocomplete, rename the file and class, .e.g PageAutocompleteCustom, edit it to do what you need. The advantage here is portability, no need to Hook into anything, get to know the inner workings of ProcessWire (especially Pagefields, etc).
  2. Lister/Lister pro: This option depends on what you mean by 'keyword'. If it means some other ProcessWire property, you can easily filter results in Lister using various criteria

 

  • Like 2
Link to comment
Share on other sites

On 4/1/2018 at 7:35 AM, kongondo said:

Depending on your use case, here's two other options

  1. Clone PageAutocomplete, rename the file and class, .e.g PageAutocompleteCustom, edit it to do what you need. The advantage here is portability, no need to Hook into anything, get to know the inner workings of ProcessWire (especially Pagefields, etc).

 thank you, I hadn't considered this possibility

Link to comment
Share on other sites

4 hours ago, neosin said:

thank you, I hadn't considered this possibility

Actually, you might not even have to rename it. If you save it in /site/modules/, ProcessWire will tell you that you have two similar modules, one in /wire/modules/ and the other in /site/modules/. It will give you a choice to decide which one to use. You'll choose the one in /site/. I'd go for renaming it though to avoid confusion and also so that the one in /wire/modules/ can still be used for its normal purpose.

  • Thanks 1
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...