I'm building a webshop and want to make some product filters with PHP and Jquery.
What's the best way to do that? For example, i want to filter my products on price, feautures, brand, colors etc. I also want to use pagination.
The filtering itself (with PHP and reload in page) won't be any problem, but how to keep the filters when going back (history button) from a product page to the category page.
The way i did it once: Make a hash in the URL, so: http://www.domain.com/categoryname/#FILTERcolor=blue&size=1 etc. My Jquery was as follows:
if(location.hash != ''){
poststr = location.hash;
pattern = /^#FILTER/
if(pattern.test(poststr)){
ajax('assets/php/ajax/productfilter.php',poststr.replace('#FILTER',''),callbackfunction);
}
}
When i went back to the category page, the hash was still in the URL, so reaload with AJAX.
Are there better ways to make product filters?