Drupal node_seach
-
I'm working on a RSS feed where full text search has to be offered - you search from some box, and get the result as a RSS. I've been trying to get node_search and do_search working but I'm missing something... but what? As far as I can tell, something like $find = node_search('search', 'type:article'); should give me a result containing all matching nodes where the type = 'article'. But how do I specify the keyword/search term? What am I missing?
-
Answer:
The http://drupal.org/project/opensearch exposes search results as RSS, no need to code it yourself. If you want a specialised form, you can just to a redirect to the OpenSearch result after processing your form. Addendum: If you really want do do your own, you can use http://api.drupal.org/api/function/search%5Fdata/6 like this: <?php $data = search_data('your searchterms here'); This searches nodes (as the default second parameter for search_data), but can also be used to search users and other things that have implemented hook_search. Also, search_data, belying the name, actually returns the formatted search results. If you want to have the raw search results, you can http://api.drupal.org/api/function/module%5Finvoke/6 http://api.drupal.org/api/function/hook%5Fsearch/6 directly, or use http://api.drupal.org/api/function/do%5Fsearch/6. Examples: <?php $results = module_invoke('node', 'search', 'your searchterms here'); $data = do_search($query, 'node'); The difference being is that invoking the hook gives you a lot more node-related data (since it runs through the node-specific search code, in addtion to the generic do_search (node.module's hook_search implementation calls do_search to get the actual work done)) and a possibly more accurate search, since the node search respects the weights you might have set in the search settings. The tradeoff is a slower search query.
kristian nissen at Stack Overflow Visit the source
Other answers
It should jsut be key:value you can use - and "" also. http://api.drupal.org/api/function/hook%5Fsearch/6 Phil
Phil Carter
Related Q & A:
- How can I disable default blocks in Drupal 7 without touching the Blocks Config admin?Best solution by Drupal Answers
- How to edit a custom region from an Omega subtheme in Drupal 7?Best solution by Drupal Answers
- How can I make Private Messages in Drupal 7 with user user pictures like in Facebook?Best solution by Drupal Answers
- Do I need to place the contributed modules inside "sites/all/modules" folder for drupal version upgradation from 6 to 7?Best solution by Drupal Answers
- How to have multiple sites on drupal 7?Best solution by Drupal Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.