Skip to content

Instantly share code, notes, and snippets.

@kongondo
Forked from somatonic/find matches example
Created June 7, 2013 09:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kongondo/5728095 to your computer and use it in GitHub Desktop.
Save kongondo/5728095 to your computer and use it in GitHub Desktop.
PW search and find matches
$words = '';
$q = $sanitizer->selectorValue($input->post->q);
$words = explode(' ', $q);
foreach($words as $word) {
$word = $sanitizer->selectorValue($word);
if($word) $selectorEmergencyContacts .= "title|label_$lang*=$word, ";
}
...
// search for Emergency Contact Addresses, match pages that have this address in "emergency_address_select" page field (in two lines!!!)
$address_matches = $pages->get(1458)->find( $selectorEmergencyContacts . " template=emergency-contact, include=hidden");
if(count($address_matches) > 0) {
// if we found Contacts, we search for objects having this address added through page reference field "address_select"
$matchesA = $pages->get(1010)->find("emergency_address_select=$address_matches, template=object");
$results->import($matchesA);
}
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment