Problem/Motivation

Hello it seems this module can be used only with the search module. It would be great to make it work with Search API.

It seems that the form alters are made on forms provided by the search module that is not allowed to be activated at the same time as Search API otherwise you get a warning.

Maybe the first step would be to make the form id configurable instead of using harcoded tests:

if ($form_id == 'search_block_form' || $form_id == 'search_form')

I installed this module and just discovered that it is doing nothing when using Search API.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

phjou created an issue. See original summary.

phjou’s picture

Status: Active » Needs review

Ok I've open a new merge request to make the form ID and the input name configurable.
I've put that in advanced settings so people go there only if they really need to since it's for developers.

I managed to see changes from better search with this module now: Search API block

There is a hook_update for websites who already have the module installed for those 2 new settings.

The code changes are not very big but should allow other modules to be able to use better search on top.

robcarr’s picture

I applied the MR via a patch and it seemed to work fine with the Search API Block module. Couldn't get it to work with a Views Exposed Filter (as a block). Thanks for the work - really useful function

ryan-l-robinson’s picture

I've tested the merge request, also using search API and the search API button module. I must be missing something and I'm guessing I'm using the wrong values for those new advanced fields. I tried using "keys" for the input name, which I got by looking at the name property of the input field, and "block-searchapiform" for the Form ID, which I got by looking at the ID of the form block. I've tried other combinations like "search-api-form" or "searchapiform" for the Form ID as well.

Can you give some more guidance of which Form ID you are looking for?

ryan-l-robinson’s picture

Update: I got it this morning through some reverse engineering. It's search_api_form, not search-api-form. It doesn't work in my theme, but is now attempting to apply to the search API block.

phjou’s picture

I just have rebased the branch so it can be merged again.

It would be nice to get that feature! Definitely blocking me from using this module.

Comment #4 was confirming that it was working.

phjou’s picture

Status: Needs review » Reviewed & tested by the community
ikeigenwijs’s picture

Status: Reviewed & tested by the community » Needs work

the patch applies on dev
but i see the default form in all instances.
theme used barrio bootstrap

in advanced settings
form id:
search-api-page-block-form-zoeken

phjou’s picture

@ikeigenwijs

Could you elaborate what needs to be changed or wrong? I am not understanding what the issue is? Do you Mean that you want to be able to configure multiple forms to use better search block?

orkutmuratyilmaz’s picture

Hello all,

I've applied @phjou's commits and it works fine. Maybe @ikeigenwijs would like to add a more detailed explanation for the own results.

Best,
Orkut

robcarr’s picture

Status: Needs work » Reviewed & tested by the community

This patch works just fine (tested on 9.5.x and 10.1). Make sure if you are using the Search API exposed form that you've either uninstalled the core Search module or addressed any conflicts with routing, URLs etc

nicholass’s picture

Patch works great!

nicholass’s picture

Only issue is the current MR diff is failing to patch with 1.6 release for me

Gathering patches for dependencies. This might take a minute.
- Installing drupal/better_search (1.6.0): Extracting archive
- Applying patches for drupal/better_search
https://git.drupalcode.org/project/better_search/-/merge_requests/1.diff (search api support https://www.drupal.org/project/better_search/issues/3236805)
Could not apply patch! Skipping. The error was: Cannot apply patch https://git.drupalcode.org/project/better_search/-/merge_requests/1.diff

phjou’s picture

I would be great if a maintainer could review and merge.

I am still waiting for this to be merged in order to add automatic compatibility for "Better Search Block" into the "Search API block" module that I maintain.

PS: I would be happy to be added as maintainer too if you need help and see this message. I see that the Drupal 10 patch is still not merged :(

yogeshmpawar’s picture

Assigned: Unassigned » yogeshmpawar

Added to review list

sirclickalot’s picture

I would also like to second the request to make the module compliant with Search API.

THANKS

yogeshmpawar’s picture

Assigned: yogeshmpawar » Unassigned
Status: Reviewed & tested by the community » Fixed

Committed & pushed to 2.0.x branch.

yogeshmpawar’s picture

New release with search api compatibility - https://www.drupal.org/project/better_search/releases/2.0.1

maxilein’s picture

Is there anything that needs to be mentioned in the readme or on the module page?

e.g.

This module can be used with core search or search api.
For search api be sure to disable the core search module ...

orkutmuratyilmaz’s picture

@yogeshmpawar thanks for the new release. Can you also add @maxilein's suggestion to the module page too?

phjou’s picture

Amazing! Thank you.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.