Fix for autocomplete

  1. <?php
  2. function example_autocomplete($string = '') {
  3.   $matches = array();
  4.   if ($string) {
  5.     $result = db_query_range("SELECT dst FROM {url_alias} WHERE LOWER(dst) LIKE LOWER ('%s%%')", $string, 0, 10);
  6.     while ($destination = db_fetch_object($result)) {
  7.       $matches[$destination->dst] = check_plain($destination->dst);
  8.     }
  9.   }
  10.  
  11.   drupal_json($matches);
  12. }
  13. ?>
  14.  
  15. <?php
  16. function example_menu() {
  17.   $items['agreement/autocomplete'] = array(  
  18.     'title' => 'Example autocomplete',
  19.     'page callback' => 'example_autocomplete',  
  20.     'access arguments' => array('access administration pages'),
  21.     'type' => MENU_CALLBACK,
  22.   );
  23.  
  24.   return $items;
  25. }
  26. ?>

Submit Fix

Any tags you'd like to associate with your code, delimitered by commas (example: Views, CCK, Module, etc).
Select the syntax highlighting mode to use.