Skip to content

Instantly share code, notes, and snippets.

@pedroborges
Created December 4, 2017 13:10
Show Gist options
  • Save pedroborges/5973ba158ad7fa8f7850da869cfe9803 to your computer and use it in GitHub Desktop.
Save pedroborges/5973ba158ad7fa8f7850da869cfe9803 to your computer and use it in GitHub Desktop.
Fuzzy Search may also be used on @getkirby page fields? You can even chain it with other field methods. https://github.com/pedroborges/kirby-fuzzy-search
<?php
// site/controllers/faq.php
return function($site, $pages, $page) {
$questions = $page->questions();
if ($query = get('q')) {
$questions = $questions->fuzzySearch($query)->toStructure();
}
return compact('questions');
};
# site/blueprints/faq.yaml
# ...
fields:
# ...
questions:
label: FAQ
type: structure
entry: >
{{question}}
fields:
question:
label: Question
type: text
required: true
answer:
label: Answer
type: textarea
buttons: false
required: true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment