Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-04-10 12:46:09

argetlam
New Member
Registered: 2008-04-02
Posts: 5

Multiple Search Filters

Hello,

I’m relatively new to Textpattern. I’m building a website for a magazine using Textpattern, and there is a specific part of the website which I need help with. It is basically a listing of vendors, which users can filter using a search form.

So the listings will basically be articles in Textpattern. I can use custom fields to enter the ‘special’ values, i.e. stuff that people need to be able to filter through — so basically three search criteria/custom fields: geographic region, vendor type, preferred vendor (yes or no). All three search fields will be drop down form fields, populated with values entered in the respective custom fields. Users can either search by one or multiple criteria (i.e. just region, or region and vendor type, etc.).

I wanted to know:

  • If this is possible to do using Textpattern.
  • If it can be done without any plugins, and if so, then how?
  • If it requires plugins, which ones would be advisable in this case, and how do I go about implementing them?

Thank you for your time and help, I really appreciate it! Looking forward to your replies.

Offline

#2 2008-04-10 13:54:11

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,726
Website

Re: Multiple Search Filters

searching by a single criteria is not a problem as you can filter by categories and custom fields using txp:article_custom. Filtering by several criteria is not so straightforward.

The free plug-in chh_article_custom allows one to filter by two criteria. It’s not been updated in a while but still works although I believe it throws some errors in test mode (which disappear when switched to live status). You’ll have to build your own combined select form. I’ve done this before with some experimentation.

By far the easiest option is to use glz_custom_fields which has an in-built command to build such a drop-down combination. Only snag: you’ll have to purchase it from Gerhard.


TXP Builders – finely-crafted code, design and txp

Offline

#3 2008-04-11 03:12:37

nabrown78
Member
From: Northampton, MA, USA
Registered: 2006-10-04
Posts: 294
Website

Re: Multiple Search Filters

Ah – great question. I have this need as well. jakob, do you happen to know if the glz_custom_field search is flexible so that I could allow users to search either for ANY of the selected words or for ALL of them? I don’t even know if that makes sense…I guess, to do either an AND or an OR search?
Thanks

Offline

#4 2008-04-11 07:14:46

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,726
Website

Re: Multiple Search Filters

Quoting from the help:

<txp:glz_custom_fields_search_form results_page="listings" searchby="Area,City,Price" />
This builds a nice search form on the front-end (only selects so far).

results_page – which page (section) should the submit button take the user to (default by default)
searchby (MUST BE SET) – which custom fields should we search by and in what order? (empty by default)

You don’t have an option to specify which kind of operator is used but it will search in combination.


TXP Builders – finely-crafted code, design and txp

Offline

Board footer

Powered by FluxBB