You are here:  » Brand filter for default search results

Support Forum



Brand filter for default search results

Submitted by teezone on Mon, 2007-12-17 19:38 in

First of all, I love the script, it does exactly what I need! Both the product & support forum are the best I have ever seen! Well done.

I have taken a suggestion from the forum & implemented a brand filter at the Category level which works great. But now I would like to provide this as a default option when someone uses the search box, is this possible?

For example:
"search.php?q=category:Books:" AND
"search.php?q=Books"

Both of these would return a brand filter.. while it may seems a little redundant, I am profiling the search box quite high, so a brand filter will make it easier to filter those results.

Thanks!!

Submitted by support on Mon, 2007-12-17 19:45

Hi,

Assuming that you've implemented pretty much the code from this thread....
http://www.pricetapestry.com/node/212

...then adding the brand filter drop-down to all pages except brand searches should just be a case of changing this line:

if ($parts[0] == "category")

...to:

if ($parts[0] != "brand")

Hope this helps!
Cheers,
David.

Submitted by teezone on Mon, 2007-12-17 19:57

Wow, you are fast! Much appreciated...

I did implement those changes, and it works for search?q=category, q=brand, and q=merchant (my own addition!).

It's the default search?q= that I can't find where to enable.. (it's possible I'm just missing the obvious)..

Thanks

Submitted by support on Mon, 2007-12-17 19:59

Hi,

After the above change, the brand filter drop-down should be displayed for any query that doesn't start with brand: - so i'm a bit confused as to why it would not be displayed. Can you add some debug code to print the value of $parts[0] before the code that decides whether or not to display the brand filter....?

Cheers,
David.

Submitted by teezone on Mon, 2007-12-17 19:59

Ohhh.. scrap that comment, I get it!!

It's not a case of enabling the page I want.. it's a case of changing the default behaviour.

Anyone who hasn't made a decision yet to buy this script.. do it NOW!! This is great stuff...

Submitted by support on Mon, 2007-12-17 20:01

No worries - thanks for your comments!

Submitted by teezone on Mon, 2007-12-17 20:59

Quick follow-up..

In order to get this to work, I removed the WHERE clause, which now defaults to the entire brand list. Is there a better way to filter the current search results.. ie. only show brands listed? I've tried to copy from other sections, but keep breaking the code :)

Thanks!

Submitted by teezone on Mon, 2007-12-17 22:33

So far, so good.. but in order to make this work (given my limited abilities!), I removed the WHERE clause... which now gives a list of all brands in the database.

Is there an easy way to filter the brands based only on the search results..? I have tried copying code from other sections, with no luck.

Thanks!!

Submitted by support on Mon, 2007-12-17 22:46

Hi,

This should be possible as it just involves taking the same WHERE clause as constructed for the main search and applying it to the SELECT DISTINCT(brand).... query. However, the WHERE clause is constructed separately for the various query types and is not in any one single variable.

Could you perhaps email me your current search.php and i'll try and patch it to do the above. I'm sure it will work - but you would need to watch the performance...

Cheers,
David.