replacing drupal 6 core search with views search

Events happening in the community are now at Drupal community events on www.drupal.org.
Posted by mallet on January 26, 2009 at 9:02pm

Hi all

I am trying to replace drupals core search with my own views search. the search in views work but only if you type its exact url would you see the views search. and this is where I am having hard time putting the two together.

I am using the function hook_menu_alter to replace the drupal core search with my views search path. heres the code thats on my custom module file:

<?php
function searchy_perm() {

return array(
'access searchy', 'administer searchy');

}
// function searchy_perm


function searchy_menu_alter(&$callbacks) {
// Example - disable the page at node/add
$callbacks['search/node']['mynameofview'] = FALSE;

}
?>

Ive been told that my callbacks might be incorrect also on the drupal forums? or if anyone can please give me an example to what I should put in my callback?

-viper

Categories: ,

Comments

simplest way to to take your

Posted by Scott Reynolds on January 26, 2009 at 9:45pm

simplest way to to take your view and configure its path to be 'search/node'. Views handles the menu_alter for you. So it will override the existing search paths

thanks for that piece of

Posted by mallet on January 26, 2009 at 10:24pm

thanks for that piece of info :)
whats strange is that when you type inside the core search and click search it displays the normal drupal results page. when you type it in again in the drupal result page, it goes to the views search but with no results which you then need to type again on the views search to finally get the result of the page.

so in short, it goes through three search results to get to the views search. have I miss out on a specific option on the views page settings?

-Viper

Ugh. The search block is so

Posted by robertdouglass on January 27, 2009 at 7:07pm

Ugh. The search block is so horrible. It has a different form id and does "funky stuff". http://api.drupal.org/api/function/search_block/6 (notice that it is search_block_form).

The important thing to remember when debugging this is that $_POST requests always get redirected to $_GET requests (http://api.drupal.org/api/function/search_view/6)

I'm guessing that there is some sort of confusion going on because of the form id.

I can see why this is

Posted by mallet on January 30, 2009 at 9:03pm

I can see why this is happening from the searchpages.inc file. how do I go about getting the form for my views search to be replaced by the default drupal search blocks? would this require editing the template.php file also?
theres quite few techniques on doing this and I am bit baffled by it. really sorry about this, as this search stuff is really new to me :(

-Viper

Why don't you not display

Posted by Scott Reynolds on January 30, 2009 at 9:47pm

Why don't you not display the search block and use your views search block.

Meaning, in the views interface create a new block. And put that block in the region you want it in. And then remove the search block :-D

By the way, I'd like to do

Posted by fumbling on March 6, 2009 at 2:32am

By the way, I'd like to do this to but I don't know how to disable the search block. I mean, I could hack core, but is there another and better way? Thanks for any instruction on this one.

admin/build/block and remove

Posted by Scott Reynolds on March 19, 2009 at 4:17pm

admin/build/block and remove the search block from the region....

I must be missing something here cause that is what I meant.

great! got it working and

Posted by mallet on January 31, 2009 at 7:02pm

great! got it working and looks fab. thanks guys. honestly, I really do appreciate the help and time you taken to help me out :)

-Viper

search code changes

Posted by ashiwebi on March 13, 2009 at 2:50pm

Is there any patch which add the searching on the basis of sorting of date,title,relevancy

I think you need to go into

Posted by mallet on March 19, 2009 at 11:51am

I think you need to go into the views and try adding either: fields or filters and adding the date, title etc and see if that works. My knowledge in views isnt that great but that should work.
theres also the Sort criteria option as well.

best of luck.

-Viper

There isn't a nice way to

Posted by Scott Reynolds on March 19, 2009 at 4:19pm

There isn't a nice way to expose Sorts. I have gotten away with it in the past by creating several views (in this case three) with the different sorts and then providing links to each one, either in the block or via theming the exposed filter form.

How about using a table??

Posted by Gabrieles on May 20, 2009 at 11:35am

Make it an unsorted table and you will have the relevancy as the default, and make it sortable with the date and title fields.
I would usually use that. Are there any cons to this approach??

I'd like to do this too and

Posted by Duplika on April 30, 2009 at 10:57am

I'd like to do this too and I can't seem to figure it out. I'm currently using "search/node/%" as the page path. Here are my questions in case someone has the free time to answer them:

  1. Are you using any arguments to replace the research results with Views?
  2. You placed a custom module at the very first post. Is that necessary?
  3. Should I include any filter?

I was used to use views fast search before but since I'm using Drupal 6, I need another solution. Any help is really appreciatted.

Drupal Soul - Drupal Services

Use the exposed filter for

Posted by Scott Reynolds on April 30, 2009 at 6:52pm

Use the exposed filter for the search. No custom module necessary.

Views Fast Search just used the same filter but instead of creating temporary tables for the search results, it did it using a sub query. Now, in Drupal 6, the search filter will not create temporary tables, it uses a subquery. Essentially, Views fast search was folded into Drupal 6 Core.

So, use the exposed filter for Search.

This doesn't work for me.

Posted by 2noame on June 24, 2010 at 5:29am

This doesn't work for me. Using search/node/% as the page path results in an Access Denied message whenever I try to use the exposed search block to search for anything.

Just confined to a table

Posted by Scott Reynolds on May 20, 2009 at 3:13pm

Just confined to a table view style.

http://drupal.org/node/331976

Posted by giorgio79 on September 28, 2009 at 4:48am

****Me and Drupal :)****
Clickbank IPN - Sell online or create a membership site with the largest affiliate network!
Review Critical - One of my sites

Themed search box

Posted by aharown07 on November 14, 2009 at 2:50pm

I've got a search box built into my theme & like it alot (based on zen classic)... is it possible to make the themed search box point to Views? Or I suppose what I really need to do is figure out how to get a Views filter to display there instead. No clue how to do that.

Search view shows all contents instead of real search result

Posted by alyyas on September 7, 2010 at 7:53pm

I am using faceted search and it is working fine.
Then i create a search result view and attach it on result page (thesearch/results/%) it will show all content data from my site instead of that search result in a nice table view style.

Here are my questions:
1. i have to use any arguments to replace the research results with Views?
2. Should I include any filter in views?

Search

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

AltStyle によって変換されたページ (->オリジナル) /