neosin Posted March 30, 2018 Share Posted March 30, 2018 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 More sharing options...
elabx Posted March 30, 2018 Share Posted March 30, 2018 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. 1 Link to comment Share on other sites More sharing options...
neosin Posted April 1, 2018 Author Share Posted April 1, 2018 @elabx thank you very much for this, much appreticated Link to comment Share on other sites More sharing options...
kongondo Posted April 1, 2018 Share Posted April 1, 2018 Depending on your use case, here's two other options 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). 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 2 Link to comment Share on other sites More sharing options...
neosin Posted April 3, 2018 Author Share Posted April 3, 2018 On 4/1/2018 at 7:35 AM, kongondo said: Depending on your use case, here's two other options 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 More sharing options...
kongondo Posted April 3, 2018 Share Posted April 3, 2018 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. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now