Jump to content

Recommended Posts

Posted

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

Posted

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
Posted

Unfortunately I got all pages of the site in the results. It doesnt matter what kind of syntax I use :(

So this doesnt seem to work.

Posted

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
Posted

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

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
  • Recently Browsing   0 members

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