Crafting the URL is the hardest part of this since you need to ensure it's crafted perfectly. However, it's just letters and symbols! So it's not THAT hard. 🙂
These custom URLs have four main parts that go together. A keyword, field, operator, and a value. When used together, they tell the block exactly which records should and should not be displayed. Here's what you need to know about each of them.
KeywordThe first part is the keyword. It tells the block WHAT we want to do. For example, if we use
searchFilter, the text we add after will be responsible for filtering the results we see. However, we can also use
sortBy and
sortOrder and the text after those will specify the order of the results. One small thing to note is that all keywords are immediately followed by the =.
Here are main the keywords you need to know.
- searchFor
- This keyword searches all visible fields of the block's records. You can have multiple field value pairings and the results will match ANY of the pairings. (You can also customize additional text fields to search. Check out the advanced example for more information about that.)
- searchFilter
- This keyword searches the specific fields you specify for specific values. With filters... there much be a match with ALL of the fields. A good example is to think of shopping on Amazon. When you add filters, you would want to only see results that match all of the filters.
- searchFilterALL
- This keyword works very similarly to searchFilter. However, use this one to find results that match fields that have more than one value. For example, list selection fields like tags. List selection fields let your users pick more than one value. You might want to search for records that have 3 tags and all tags must be present.
- sortBy
- This keyword is responsible for sorting your records by the specific field your choose.
- sortOrder
- This keyword works with the sortBy keyword. It tells the block whether to sort in ascending order or descending order.
FieldThis one is easy! It's just the name of the field you want to search for or filter by.
Format: Field Name.
Example: Job title
OperatorThe third part is the operator. The operator is the tool that compares the field and the value. For simple with text searches it's just a simple colon. It tells the block to find all records where the field you specified 'contains' the value that comes after the colon. For more advanced searches however you may want to find all the salaries that are above $60k. Here you would use the greater than symbol instead.
Here are all the operators you need to know:
- : (Colon)
- This symbol means contains. This is used when searching text for other text that matches. (this is used for the majority of the field types)
- Everything below is used for numeric/price/date fields. The only variables that must have an equals sign as an operator are the 4 sort variables.
- = (Equals)
- This symbol means there must be an exact match. This is helpful when you want to find fields that are an exact number for example.
- != (Not equal)
- This symbol will return results where the field specified before it is not equal to the value after.
- > (Greater than)
- This symbol means that the value that comes after is greater than that of the field before it.
- < (Less than)
- This symbol means that the value that comes after is less than that of the field before it.
- >= (Greater than or equal to)
- Same as above except it will also show the exact matches.
- <= (Less than or equal to)
- Same as above except it will also show the exact matches.
ValueAnother easy one. This is just the value that you want to compare to the field that you specify before your operator (as mentioned above).
The only special thing you need to know here is that this is where you will put your form's merge fields. That's because when we publish the page and they are used in the URL, they will be converted to the values of the form that your customers add when they are searching.
THIS is how your customers are able to search and filter your content with their unique search criteria.
TogetherWhen put together, our segments look like this:
Format: searchFilter=Field Name:[Field Name]
Example: searchFilter=Job Title:
The only keywords that don't have to follow this format is the sortBy and sortOrder. For sortBy you just need to specify the field name. For sortOrder, you just need to specify to sort by ascending or descending. You can also use the short values for those: ASC / DESC.
To search multiple fields and values using the same keyword, separate multiple segments with semicolons.
searchFilter=Field Name:[Field Name];Field Name:[Field Name]