SHARE
TWEET

Untitled

a guest Jun 20th, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. name, weight
  2. dog, -2
  3. cat, 1
  4. zebra, -5
  5. dolphin, 3
  6. bee, 5
  7.      
  8. function zoo_facetapi_sort_animal(array $a, array$b) {
  9. $a = db_query("select weight from {animal} where name = :a", array(':a' => $a['#markup']))->fetchAssoc();
  10. $b = db_query("select weight from {animal} where name = :b", array(':b' => $b['#markup']))->fetchAssoc();
  11.  
  12. $a_value = (isset($a['weight'])) ? $a['weight']:0;
  13. $b_value = (isset($b['weight'])) ? $b['weight']:0;
  14.  
  15. return strnatcmp($b_value, $a_value);
  16. }
  17.      
  18. zebra
  19. dog
  20. cat
  21. dolphin
  22. bee
  23.      
  24. Warning: uasort(): Array was modified by the user comparison function in FacetapiWidget->applySorts() (line 230 of /var/www/zoo.dev/sites/all/modules/facetapi/plugins/facetapi/widget.inc).
  25.      
  26. /**
  27.  * Implements hook_facetapi_sort_info
  28.  */  
  29. function zoo_facetapi_sort_info() {
  30.   $sorts = array();
  31.  
  32.   $sorts['active'] = array(
  33.     'label' => t('Animal ...'),
  34.     'callback' => 'zoo_facetapi_sort_animal',
  35.     'description' => t('Sort by whether the animal is ...'),
  36.     'weight' => -50,
  37.   );
  38.  
  39.   return $sorts;
  40. }
  41.  
  42.  
  43. function zoo_facetapi_sort_animal(array $a, array $b) {
  44.   ...
  45. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top