1
Answers
Vote up!
0
Vote down!

Search facet with submit button?

Hi all,
I have several search facets that work great on search pages, and even facets blocks on product pages, but I would like a search facet with "submit" button for the front page.

So, I need block(s) containing the taxonomy terms with checkboxes and a "submit" button, so that when you click on it you get the page with the search results.

How do I do that?

Asked by: bandb
on March 30, 2013

1 Answer

Vote up!
1
Vote down!

You could create the url using the following:

// This shows us a search result with two colors and a brand

/products?f[0]=field_brand%3A51&f[1]=field_product%253Afield_color%3A14&f[2]=field_product%253Afield_color%3A41

/products? <-- that's the first part, will always be like this

f[0]= <-- that's the first facet, will likely only need one (which is zero here)

field_brand <-- that's the field name that we're faceting. Will likely be a color field or a brand field or a size field

%3A <-- that's the combining character... essentially "="

51 <-- that's the term_id that we're looking for in that field

%253A <-- that's the indicator that we have another facet

So ... some php might look like this:

<?php
foreach ($terms as $term) {
  echo
'<li><a href="/products?f[0]=field_something_cool%3A' . $term->tid . '">' . $term->name . '</a></li>';
}
?>

Wouldn't take much to turn that into a checkbox-configurable form box that uses "drupal_goto()" to send you to the search results.

Josh Miller
Answer by: Josh Miller
Posted: Apr 2, 2013