3

I'm updating a site to use Search API (with Search API DB) instead of the built-in search module. I've set up my Search API server and search, indexed everything, and now am just trying to replace the old search box with the new one in the theme.

But I can't find any way to do this.

Before disabling the built in search module, there was only one search block. After disabling, there are none, including after clearing caches. According to Integrate core search block with search_api and Solr and various other sources, I should get a search block automatically, but I don't.

Before, I got the search box into my template .tpl file with <?php print render($search_box); ?>. After, this throws an error.

I can't find anything on what to use instead, and the relevant documentation page about search forms talks only about search results pages, not about how to put a search box on other pages. I'm confused at how hard it is to find how to do something so basic. I can't find anything about how to find the code to either populate this variable in template.php or access any inbuilt template variable.

How do I show a basic search block on the front page that integrates with search api? is similar but the asker reports its answer doesn't work, and I'm not fussy about whether it's specifically a block or specifically on the front page or connected to a view, I just want the search input element.

How do I add a Search API search box to a theme? How do I make it generate the block or load the search box from code?

2

In Views Under the Filter Criteria click the 'Add' button. Choose 'Search: Fulltext search'. Check the checkbox 'Expose this filter to visitors, to allow them to change it'. Place the block.

When people submit a search via this Block it will only take them to the View page that is was created on. If that Page is Disabled in your View it will not work. It will give you a page not found.

If you are using a Content Pane in a Panel instead of a Page you need to go into the 'Allow Settings' and check the checkbox 'Path override'. That will allow you to change the path to the path you are using in your Panel page.

4

Maybe not the best option, but to get a usable Search Block from the Views module (that includes the Search API Views submodule), you need to activate the "Expose Form >> Exposed form in block" option in your Views advanced configuration. This is what it looks like:

enter image description here

Good luck!

1

Stefanos and heart-cooks are correct, I just wanted to mention that you don't need to try to make a block using the typical views tab as in "add a new block".. ie, don't use this: enter image description here

Clicking on the "expose form in block" is enough to create the block.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.