Jump to content

Searching select option field type possible?


Juergen
 Share

Recommended Posts

Hello @ all,

I want to know if it is possible to make a site search also for select option fieldtype?

In my case I use this fieldtype to choose the manufacturer of a product.

The field itself is called "manufacturer". I have tried to include the field in my site search as "manufacturer", "manufactuer.title", manufactuer->title" but no luck.

My goal is to include all products in the results if someone enters the manufacturer name in the search field.

Any hints?

Best regards

Link to comment
Share on other sites

Both "manufacturer=$optiontitle" and "manufacturer.title=$optiontitle" should work, unless you have separate values/titles configured and want to search for the value, then "manufacturer.value=$optionvalue" is the way to go. Both .value and .title support text matching.

  • Like 1
Link to comment
Share on other sites

Correct Syntax for Fieldtype Select Options

$optionsfield // return id (string)
$optionsfield->id; // return id (int)
$optionsfield->title; // return string USE THIS or
$optionsfield->value; // return empty string or value (if your option settings like '1=value|title')

// dot syntax in selector string
$pages->find('optionsfield.id=2');

Docs:
https://processwire....tions-on-a-page
or
https://processwire....d-on-selections


@BitPoet

Both "manufacturer=$optiontitle" and "manufacturer.title=$optiontitle" should work,

$page->manufacturer return id as a string, NOT the title!

  • Like 3
Link to comment
Share on other sites

I found the solution:

My search term variable is $q. This is what causes the problems because I didnt include it $q. Instead I used $optionvalue as mentioned above

So the syntax is

manufacturer.title=$q

Now I got the correct results

thanks all

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...