Juergen Posted March 14, 2016 Share Posted March 14, 2016 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 More sharing options...
BitPoet Posted March 14, 2016 Share Posted March 14, 2016 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. 1 Link to comment Share on other sites More sharing options...
Juergen Posted March 14, 2016 Author Share Posted March 14, 2016 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. Link to comment Share on other sites More sharing options...
kixe Posted March 14, 2016 Share Posted March 14, 2016 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-pageorhttps://processwire....d-on-selections @BitPoet Both "manufacturer=$optiontitle" and "manufacturer.title=$optiontitle" should work, $page->manufacturer return id as a string, NOT the title! 3 Link to comment Share on other sites More sharing options...
Juergen Posted March 14, 2016 Author Share Posted March 14, 2016 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now