Closed (fixed)
Project:
Search Lucene API
Version:
6.x-2.0-rc1
Component:
User interface
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
10 Dec 2009 at 16:03 UTC
Updated:
12 Jul 2010 at 06:01 UTC
Is there any way to display a result count when doing Lucene searches? e.g. displaying 10 from 25 etc.
Comments
Comment #1
cpliakas commentedHi Quinten.
Search Lucene API uses the standard global pager variables, so you have access to all this information. See the code below:
You can use this information in your display logic to do what you illustrated above.
Thanks,
Chris
Comment #2
cpliakas commentedP.S to get the offset and first item, you would have to do the following:
Comment #3
Quentin commentedHi Chris,
Thank you for your quick response! I have some basic PHP knowledge, but I am not much of a programmer.... is this supposed to go into the luceneapi.module file?
Thanks,
Quentin
Comment #4
cpliakas commentedHi Quentin.
You do not want to modify the Search Lucene API files. It is generally bad practice to modify Drupal core code and contributed modules because it introduces unintended bugs and breaks upgrade paths. See the following post for more info : http://drupal.org/node/144376. Fortunately Search Lucene API does implement theme hooks fairly well, so you are able to modify what is displayed in a custom theme. Unfortunately a theming tutorial is out of the scope of this support request, but I will point you to the post at http://adaptivethemes.com/theme-your-search-results for a quick overview on how you can get this information into your templates. The pagination variables described above will be set in the preprocess function, and you can chose where to display it in the custom template.
Hope this points you in the right direction,
Chris
Comment #5
Quentin commentedHi Chris,
Thank your for your quick response. I have been fiddling around with the code above, but I haven't managed to get it up and running as yet... I'll give it another go soon.. must be my PHP incompetence.. :-p
Thanks,
Quentin
Comment #6
walker2238 commentedThis is a bit off topic but another neat idea to expand on this would be by adding the words the user is searching for by using something like search_get_keys() I assume. That way you get the full phrase.
So you could have "(x-amount) results found for (my entered search term)."
Comment #7
cpliakas commentedMarking as closed after a long period of inactivity.