Craft CMS Asked on April 8, 2021
I have entries using the Smart Map address field. I need to get just the entries that have a combination of city and state (city = "Beverly Hills" AND state = "CA"). I am currently only trying to get simpler search state working and only then will I move to state/city. I can get a "fuzzy" that to my understanding will get everything that has "CA" in any of the fields using:
{% set meetings = craft.entries.section('meetings').search('address:' ~ 'CA') %}
But I want to understand how to create a more specific search that specifically finds ‘CA’ in address.state.
When I try:
{% set meetings = craft.entries.section('meetings').search('address.state:' ~ 'CA') %}
the search returns nothing. No errors either.
Questions:
It's more "filtering" than "searching", but take a look at this...
Set a filter
parameter when creating your element criteria model...
{% set params = {
filter: {
city: 'Beverly Hills',
state: 'CA'
}
} %}
{% set meetings = craft.entries.address(params) %}
Correct answer by Lindsey D on April 8, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP