Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

better search function #33

Closed
jywarren opened this issue Nov 22, 2011 · 7 comments
Closed

better search function #33

jywarren opened this issue Nov 22, 2011 · 7 comments

Comments

@jywarren
Copy link
Owner

Barnraising vs Barn raising, autocompletion, just better results?

sketch

@adamdgriffith
Copy link
Collaborator

request ability to search within just the plots archive

@jywarren
Copy link
Owner Author

Good call. Maybe this can be part of the archive front page redesign: #54

You can already narrow to only searching maps, but a dedicated box for that on the map page would be nice:

Picture 4

@jywarren
Copy link
Owner Author

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();
    });
  });
};

@jywarren
Copy link
Owner Author

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

@jywarren
Copy link
Owner Author

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

@jywarren
Copy link
Owner Author

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

@jywarren
Copy link
Owner Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants