Closed (fixed)
Project:
Services
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
9 Apr 2009 at 15:55 UTC
Updated:
29 May 2009 at 23:37 UTC
the search service as it stands either returns far too much data - or (in the simple search) doesn't provide the node ID which is fairly critical to actually do anything with the returned data, I've modified the code slightly so that this gets returned:
//lines 12-39 of search_service.inc
function search_service_nodes($keys, $simple = FALSE) {
// define standard keys for simple set
// added 'node' into this array
$stdkeys = array('node', 'link', 'type', 'title', 'user', 'date', 'snippet');
// invoke the search hook to generate results
$results = module_invoke('node', 'search', 'search', $keys);
if ($results and is_array($results) and count($results)) {
// if simple results requested, remove extra data
if ($simple) {
$num = count($results);
for ($i = 0; $i<$num; $i++) {
$keys = array_keys($results[$i]);
foreach ($keys as $key) {
// only add the node id (nid)
if ($key == 'node'){
$results[$i][$key] = $results[$i]['node']->nid;
}
if (!in_array($key, $stdkeys)) {
unset($results[$i][$key]);
}
}
}
}
return $results;
}
return services_error(t('Search returned no results.'));
}
Comments
Comment #1
marcingy commentedComment #2
marcingy commented