Last active
May 20, 2019 16:07
-
-
Save jacmaes/5bf045cd1d654f15deb9381ab074efbf to your computer and use it in GitHub Desktop.
advanced-selectors-search-engine.php #pw #php
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 | |
# https://processwire.com/blog/posts/processwire-3.0.13-selector-upgrades-and-new-form-builder-version/#new-selectors-as-regular-arrays | |
# New selectors as associative or regular arrays | |
$results = $pages->find([ | |
'template' => ['basic-page', 'product'], | |
'title|body%=' => $sanitizer->text($input->get('q')), | |
'categories' => $sanitizer->intArray($input->get('categories')), | |
'sort' => '-created' | |
]); | |
$results = $pages->find([ | |
['template', ['basic-page', 'product']], | |
['title|body', '%=', $input->get('q'), 'text'], | |
['categories', '=', $input->get('categories'), 'int'], | |
['sort', '-created'] | |
]); | |
# Search by tags | |
# https://processwire.com/blog/posts/pw-3.0.106/#a-new-way-to-search-with-upgraded-tags-for-fields | |
$results = $pages->find("search_text~=text"); | |
# Search by FieldType | |
# https://processwire.com/blog/posts/processwire-3.0.91-core-updates/ | |
$items = $pages->find("FieldtypeTextarea%=coffee"); | |
$pages->find("FieldtypeTextarea|FieldtypeText|FieldtypePageTitle%=coffee"); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment