Closed jywarren closed 12 years ago
request ability to search within just the plots archive
Good call. Maybe this can be part of the archive front page redesign: https://github.com/jywarren/plots/issues/54
You can already narrow to only searching maps, but a dedicated box for that on the map page would be nice:
OK, i installed search_autocomplete, the drupal module. It looks great and has namespacing (like you can type "map: blabla" to search only within maps.
However it's having some trouble with our version of jQuery (1.7.x):
Uncaught TypeError: Object [object Object] has no method 'autocomplete'
I tried dropping in the most recent jquery.autocomplete.js but the one in the module is not really a vanilla copy, it's modified for use with Drupal. I think if we can recode the top 16 lines of that file, (/sites/all/modules/search_autocomplete/js/jquery.autocomplete.js), we could pull this off.
Drupal.behaviors.search_autocomplete = function(context) { $.each(Drupal.settings.search_autocomplete, function(key, value) { $(Drupal.settings.search_autocomplete[key].selector + ' input:first').filter(':not(.search_autocomplete_processed)').addClass('search_autocomplete_processed').autocomplete( Drupal.settings.search_autocomplete[key].url, { dataType: "json", cacheLength : 20, matchContains: true, minChars: Drupal.settings.search_autocomplete[key].minChars, selectFirst: false, max: Drupal.settings.search_autocomplete[key].max_sug } ).result(function () { $(this).submit(); }); }); };
Hmm, i just removed the trailing ".result(function..." and now it is almost working... but the following AJAX request fails. Something wrong with url aliasing?
http://publiclaboratory.org/search_autocomplete/3/autocomplete?q=camera&limit=10
OK, here is the problem. The correct URL is:
http://publiclaboratory.org/search_autocomplete/3/autocomplete/camera&limit=10
not
http://publiclaboratory.org/search_autocomplete/3/autocomplete?q=camera&limit=10
Now i need to make sure that form javascript goes to the correct url
docs say: * If options.queryParamName === false, append query to url instead of using a GET parameter
https://raw.github.com/dyve/jquery-autocomplete/master/src/jquery.autocomplete.js
sweet! it's working but now the returned query is not parseable by search_autocomplete, since probably the new jquery.autocomplete expects a new and different format for search results.
Now it's even coming back as json, without erroring. I updated the jquery.autocomplete.js options, and all seem to be OK, it just doesn't actually display the response now:
queryParamName: false,
remoteDataType: "json",
useCache: true,
maxCacheLength : 20,
matchInside: true,
minChars: Drupal.settings.search_autocomplete[key].minChars,
selectFirst: false,
maxItemsToShow: Drupal.settings.search_autocomplete[key].max_sug
Barnraising vs Barn raising, autocompletion, just better results?