Created
December 4, 2017 13:10
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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'); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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