1

I want to build the ability for the user to be able to filter by certain categories when browsing an existing category. As well as this I would like the user to be able to control the ordering of products (order by price, title, sale) and perhaps (tbc) the ability to choose how many products are shown. Finally, some products depending on the limit will have pagination for both the unfiltered results but also the filtered results.

The filters currently are brand and life-stage but there could be others depending on the growth of the site.

I do have these all working with Craft in isolation I am really unsure of the best way to pull these together so that they all work in harmony. Currently if you filter on a brand and then change the order the brand is lost and goes back to the main category view. This is because I am using query-strings to filter the brands, life-stage, ordering and limit.

Any thoughts on the best way to tackle this from a front-end approach and also templating approach?

I should perhaps add that the ability to filter by categories (brands etc) sits in a different location to the order function. So this might make things slightly more tricky as perhaps form could work to accomplish this?

Thanks

  • 1
    The easiest by far (in my opinion) is to use Ajax, so you don't have to care about page reloads or setting filters to create a valid url. For these things I always prefer to use PHP instead of Twig. If you want I could show you a rather complex search example I did here thaff.secondred-elab.selfip.org/… – Robin Schambach May 20 '18 at 21:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.