2

I followed the instructions @ Drupal: how to access to Drupal's APIs with a standalone php script? , however, my search query is returning 0 results (an empty array). I have confirmed that the same search term returns a result if executed from my drupal web page.

<?php
    chdir("drupal");
    define("DRUPAL_ROOT",".");
    require_once './includes/bootstrap.inc';
    include 'drupal/modules/search/search.api.php';
    drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
    $keys = array("harry","potter");
    $result = hook_search_execute($keys);
    print_r($result);
?>

Can anyone give me some pointers as to why this isn't working? Many thanks!

Community
  • 1
  • 1
Alex O
  • 21
  • 2

1 Answers1

0

The problem is that you are calling hook_search_execute directly--this is only meant for API documentation.

So, no need to include search.api.php. Instead, take a look at search_data(), which calls a specific module (user module, or node module, for example) invoking that hook. If you are trying to search nodes, you can call node_search_execute() directly.

jhedstrom
  • 3,378
  • 1
  • 23
  • 19