0

In Drupal 7, I'm currently using the default core search, and a view for node search results. I have a global text to pull in the replacement pattern for the term that were searched for. I get the token by adding the contextual filter Search: Search Terms I am using the replacement pattern %1 as seen in the picture:

enter image description here

Then I put <span class="MY-CLASS">You searched for:</span> <b> %1 </b> in my global text to display the keywords that were searched for:

enter image description here

This all works great for Drupal core search, but I am not finding a way to do this with the view in Search API? I am using Database Service, and a view built from the database index I created. I have tried to find a field such as keywords for the full text search, but since the view is based off of indexed content, I am not able to get those type of fields added, to make them available for tokens, even via relationships. Maybe there is a better way to build the view?

1 Answer 1

0

The problem I was having here is my view that I was trying to build for search API was using a full text search exposed filter rather than a contextual filter. The contextual filter provides the search term title and search term input tokens that are pictured above. The exposed filter will not produce them. Live and learn.

EDIT: There is a bit of a workaround I found but it was an implementation I would not recommend. I was using Drupal core search blocks with Search API view's contextual filters together. I was able to add the contextual filter, get the token, then remove the contextual filter. That somehow allowed the token to work in that context.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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