I have a custom content type called 'Regions', which simply has a title field. Example values are: Asia, North America, Ocenia, etc.
I've set up a view for this list and a REST export for it, so /regions
gives me a simple list:
[{"title":"Asia"},{"title":"North America"},{"title":"South America"},{"title":"Ocenia"}]
I want to filter the results, so I added a contextual filter on the title field, making /regions/Asia
show only Asia:
[{"title":"Asia"}]
How do I implement a wildcard search? Something like as
should match Asia
and amer
should match both North America
and South America
. I'd like to do something like /regions?title=Asia
I referred to this guide on setting up contextual filters, but the following doesn't seem to work for me:
This query works as a SQL
LIKE
statement so you can send just a piece of the name and Views will try to find all recordsLIKE
that argument, example, I have a brand calledLand Rover
but if I just sendLand
as an argument it will work http://dev-cars-api.pantheonsite.io/api/cars/Land
The URL in the quote is no longer online, so I can't check if it actually works. For me, only entering a full, matching item title works. I can't even specify a title with spaces, so /regions/North+America
is also blank for me.
My Drupal version is 8.4, running on PHP 7.1.